Amazon Interview Questions
- 0of 0 votes
Answersswap kth element from the beginning and kth element from the end of linked list.
- anonymous June 21, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding - 0of 0 votes
Answersprint a decimal number in binary form. eg: number=10 or 2.22 or 0.876 ....
- anonymous June 21, 2013 in India
required to print only four number after decimal point| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding - 0of 0 votes
Answersfind all elements in the loop of an linked list....( linked list may or may not have loop)
- anonymous June 21, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding - 0of 0 votes
AnswersGiven a binary tree, for each node in the tree find the nodes with value greater than or equal to current node and sum them with the value of the current node. replace the node value with the above calculated sum....
- anonymous June 21, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding - 1of 1 vote
Answersgiven an array of number. find the largest possible sum of numbers in the array.
- anonymous June 21, 2013 in India
Condition: no two elements should be picked consecutively and position of elements in the array should not be changed..| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
Answersgiven a binary tree in which a node can have two childs or no child. All the leaf nodes are represented as 'L' and parent nodes are represented as 'P'.
- anonymous June 21, 2013 in India
Given the preorder of the tree (string eg : PPPLLP....) find the depth of the tree.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 2of 2 votes
AnswersIs it possible to compare two Binary trees for equality in iterative manner without using extra space?
- Algorithmist June 17, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersGiven a list of test results (each with a test date, Student ID, and the student’s Score), return the Final Score for each student. A student’s Final Score is calculated as the average of his/her 5 highest test scores. You can assume each student has at least 5 test scores.
You may use the JDK or the standard template library. The solution will be evaluated on correctness, runtime complexity (big-O), and adherence to coding best practices. A complete answer will include the following:
Document your assumptions
Explain your approach and how you intend to solve the problem
Provide code comments where applicable
Explain the big-O run time complexity of your solution. Justify your answer.
Identify any additional data structures you used and justify why you used them.
Only provide your best answer to each part of the question.
Use the following skeleton for your solutions.
Java:
- aopencv June 16, 2013 in United Statesclass TestResult { int studentId; String testDate; int testScore; } public class FinalScoreQuestion { Map <Integer, Double> calculateFinalScores (List<TestResult> results) { }
| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Java Problem Solving Sorting - 2of 2 votes
AnswersDesign Elevator system. And then write an algorithm for that Design such that, the user request should be completed in logN time in a N story building with M elevators,
- fbrubacher June 16, 2013 in United States for Search| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersWrite a program to remove duplicates from array of prime numbers.
- onlinesoumitra June 14, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 6of 6 votes
AnswersIn a certain language which has same alphabets as in english language (ie. a-z), but the order of the alphabets is different (for eg 's' is the first character, 'g' is second, and likewise). Given a dictionary of this new language (which has words arranged according to new alphabetical order), FInd out the order of alphabets in this language.
- sgarg June 09, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Google SDE1 Software Engineer / Developer SDE-2 Algorithm - 0of 4 votes
AnswersGiven a matrix consisting of nos you can print the max length of sequence possible where in a sequence each consecutive nos have a diff of +1 or -1.
- bharat June 06, 2013 in United States
Ex :
3 5 7 3
4 5 8 1
6 4 5 2
here sequence is
3
4 5
4 5| Report Duplicate | Flag | PURGE
Amazon SDE1 - 2of 2 votes
AnswersHow to find in a binary tree, whether all leaves are at same level or not, and return a boolean value after identifying this.
- seth June 04, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 1of 3 votes
AnswersGiven a binary tree, a complete path is defined as a path from root to a leaf. The sum of all nodes on that path is defined as the sum of that path. Given a number K, you have to remove (prune the tree) nodes from the tree which lie on a path having sum less than K.
- seth June 04, 2013 in India
Note: A node can be part of multiple paths. So we have to delete it only in case when all paths from it have sum less than K.| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersWrite code to Print the power set of given string
- sachin323 June 03, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersBar raiser round
- sachin323 June 03, 2013 in United States
Write code to return Kth smallest node from BST| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersFind a pair of numbers from Array that will sum up to K
- sachin323 June 03, 2013 in United States
me : I know this , told him both approaches using sorting as well as HashTable| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersWrite a Program for Dictionary which has functionality of lookup and insert . This program should be able to add words on the fly
- sachin323 June 03, 2013 in United States
I wrote simple code using HashTable
follow up
1) Now we are getting too many words what happens
me: Hashtable will dynamically resize resulting into performance hit . Also they might get hashed to same location as well as we might run out of main memory
2) Okay you are out of main memory , How will you scale this program
me: I will create buckets of HashTable lets say 26 buckets for one for each alphabet and would put them on different machines
3) Lets say you are out of memory on those machines too
me: Okay I need to put them on secondary storage . Here we can have fileSystem or Database . I chose database . I will create simple DB schema of BucketNumber and word .
I will use buckets on main memory as cache , if we are not able to find a word in the bucket then query databse with bucket number and words then remove the least number times looked up word (every time we lookup a word we increament the count i.e value in key,value pair on hashtable) from that bucket and add this word .
I mentioned that bottleneck in this case will be every time a word is not present we need to query DB which usually has high latency which will result into performance hit
4) Lets say we are okay with latency but what if we are getting inserting words between that are only between only in two buckets ex. words starting from a and b only| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersA stirng is represented using a linked list how will you find if it the string is palindrom.
- rawat011 May 31, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test SDE1 Algorithm - 3of 3 votes
AnswersThere are N floors and N persons each one is tagged with some random unique number between 1 to N(represents floor number).
- bharat May 31, 2013 in India
We have a lift which can accommodate one person at a time. Every person is in some random floor.
Initially lift is at floor 1 and all floors have single person. Problem here is.. we have to move the persons to their corresponding floor with minimum travelled distance of lift.
Restriction : Lift can have at most one person at a time.
One more thing we have to think of is .. At a time, we can keep more than one person in a floor.. means, we don't necessarily need to take the person out from the floor if we keep another person on the same floor.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersFor a given BST, connect each of its right child to its inorder successor.
- Razz May 27, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - -3of 3 votes
AnswersYou have an array of binary numbers as "00001101000001010100000..."... We need to find the First occurrence of 1 in this series.. using binary search.
- imvrajendra May 21, 2013 in India
we need to design an algorithm of complexity less than O(n).. and we need to use binary search strictly..| Report Duplicate | Flag | PURGE
Amazon SDE1 Arrays - 0of 0 votes
AnswersGiven a Binary Search tree along with the parent pointer, find the next largest node for the given node. Give the time and space complexity. The node Structure is
- chetan12189 May 14, 2013 in India
class Node {
Int data;
Node left;
Node right;
Node parent;
}| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
Answers1. N-Petrol bunk problem: There are n petrol bunks located in a circle. We have a truck which runs 1 km per 1 liter (mileage 1kmpl). Two arrays are given. The distances between petrol bunks are given in one array. Other array contains the no of liters available at each petrol bunk. We have to find the starting point such that if we start at that point , you we would able to visit entire circle without running out of fuel. Initially truck has no fuel
- blackfever May 05, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswerThere is a HealthMonitor and two Servers (Primary and Secondary), all connected to one and another.
- JSDUDE May 04, 2013 in United States
The HealthMonitor keeps pinging both the servers at specific time intervals and waits for their response for a time-out period after the request has been sent.
The server responds with a health status of itself and of its neighbor (meaning Primary responsds: OK; NEIGHBOR_OK)
Implement the server's code to send and receive responses and then take action based on response.| Report Duplicate | Flag | PURGE
Amazon SDE1 Threads - 3of 3 votes
AnswersWrite a class that will have following functions:
- JSDUDE May 04, 2013 in United States
long CheckOut()
CheckIn(long)
Range of values is 1 to LONG_MAX
At any given point in time checkout should return the minimum available LONG number
Checkin can return the value back
No need to check for border conditions (e.g. check out when all values are exhausted)
Implement:
1. long checkout()
2. void checkIn(long input)| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersWrite a class For Contacts on a device
- JSDUDE May 04, 2013 in United States
Implementing Search a contact was the biggest problem I faced (because search should potentially search: FirstName, LastName, Address, PH#, Email etc)| Report Duplicate | Flag | PURGE
Amazon SDE1 Object Oriented Design - 0of 0 votes
AnswerWrite a class for a parking garage:
- JSDUDE May 04, 2013 in United States
One level
One entry point
No membership or payments required
Handles multiple types of cars| Report Duplicate | Flag | PURGE
Amazon SDE1 Object Oriented Design - 0of 0 votes
AnswersImplement:
1. a search that will return all the strings that match a sub-string
2. an insert into this datastructure
- JSDUDE May 04, 2013 in United StatesClass { Insert (string str){}; List<strings> Predictions(string subString){}; }
| Report Duplicate | Flag | PURGE
Amazon SDE1 Trees and Graphs