Amazon Interview Questions
- 0of 0 votes
AnswersWrite test cases for,
- qe.expert March 18, 2015 in India
Testing a API , which takes URL as input which points to a html page, finds a specific TAG and extracts all integers between the tags, sorts the numbers in ascending order and writes it to a file| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Testing - 1of 1 vote
AnswersTell the following 3 letter in the sequence
- qe.expert March 18, 2015 in India
A E F H I K _ _ _| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Brain Teasers - 1of 1 vote
AnswersCheck if the given binary tree is a unival tree. (all nodes have same value)
- tbag March 16, 2015 in United States
Follow up- Count the number of unival subtrees in a binary tree.| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 0of 0 votes
AnswersGiven an integer of a certain bit length, does it have an even or odd number of parity bits?
- tbag March 16, 2015 in United States
Optimization - Can you do this recursively in one line of code?| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 2of 2 votes
AnswersYou are given a function: List<TimeSlot> getTimeSlots (String friend)
- h3ssam March 15, 2015 in United States
Assume getTimeSlots() returns available times for a friend, sorted in order, with no overlap.
Assume TimeSlot has comparable function
You want to schedule a meeting among all of your friends, such that all can attend.
Implement a function to get the first 3 common TimeSlots among all your friends:
List<TimeSlot> get3CommonTimeSlots (List<String> friends)
user1 1-2pm, 3-4pm, 7-8pm
user2 1-2pm, 5-6pm| Report Duplicate | Flag | PURGE
Amazon Intern Algorithm - 0of 2 votes
AnswersGiven an array of random integers and a sum value, find two numbers from the array that sum up to the given sum.
- shoryagupta1493 March 12, 2015 in United States for Amazon Fresh
eg. array = {2,5,3,7,9,8}; sum = 11
output -> 2,9
Implement in O(n) time complexity. Find all distinct pairs. (2,9) and (9,2) are not distinct.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersWhat are the advantages of an array over a linked list? and vice versa.
- shoryagupta1493 March 12, 2015 in United States for Amazon Fresh| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersDesign Twitter Timeline
- nvinet March 11, 2015 in United Kingdom for Instant Video| Report Duplicate | Flag | PURGE
Amazon Software Development Manager Object Oriented Design - 4of 4 votes
Answersin a tree any root can have any number of children. Every node has an integer value. Find the maximum length on consecutive number sequence anywhere in the tree. For example if root is 2 and one child is 3, its child is 4 its child is 6 then max length will be 3. I was able to write the code the find of one sequence but when one sequence ends and other starts I was not able to handle that case. I think its hard to do by recursion. Is there any other trick or algorithm for this??
- ajrules2105 March 10, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Trees and Graphs - 0of 0 votes
AnswersGiven a 1D array with integers,print vertical bars of # such that if a[i] = n, then print # n times from the bottom.
- bestluck March 10, 2015 in United States
For eg, {1,4,3,2}
o/p : #
# #
# # #
# # # #| Report Duplicate | Flag | PURGE
Amazon Software Engineer Intern Java - 4of 4 votes
AnswersGive a path get it's canonical form. So for example if you have path in the form e/../../a/d/./../b/c then you should return a/b/c.
I have the solution but it's not the most optimal or the best solution. I just wanted to see what others have.
- cyb March 09, 2015 in United Statespublic String canonicalPath(String path){ if(path == null || path.isEmpty()){ throw new RuntimeException("incorrect path provided"); } String[] chunks = path.split("/"); Stack<String> s = new Stack<String>(); List<String> arr = new ArrayList<String>(); for(String chunk: chunks){ if(chunk.isEmpty() || chunk == "."){ System.out.println("skipping"); }else{ if(!s.isEmpty() && s.peek().equals("..") && !chunk.equals("..")){ while (!s.isEmpty()) { if(s.peek().equals("..")){ s.pop(); }else{ s.pop(); break; } } s.push(chunk); }else{ s.push(chunk); } } } StringBuffer sb = new StringBuffer(); List<String> list = null; if(!s.isEmpty()){ list = new ArrayList<String>(s); } if(list != null){ for(String ss : list){ sb.append("/"+ss); } } return sb.toString(); }
| Report Duplicate | Flag | PURGE
Amazon Software Developer Data Structures - 0of 0 votes
AnswersGiven a list of integers, e.g.:
{ 2, 6, 7, 9, 1, 0, 1, 2, 3, 6 }
.
- rokuumlabs March 05, 2015 in United States
Write an time efficient algorithm to find the longest subset in which the difference between the minimum and maximum numbers is 0 or 1.
The subset can have a length of 0 and can hold any of the values in the original array (order not matters).| Report Duplicate | Flag | PURGE
Amazon Algorithm - 2of 2 votes
AnswersLink all the level order nodes to makes a linked list with the first node of each level acting as the root of that linklist.
- catlover February 27, 2015 in India
10
/ \
6 17
/ / \
4 14 19
So the Linklist will be
10->null
6->17->null
4->14->19->null| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersYou have three containers, small, medium and large. Passenger comes in, checkin the luggage. You have to store the baggage in the appropriate container and generate a unique token number. Then passenger should get back the bag using the same token number. Trick was if small container is full store in medium if available or large. Now if the large bag comes in and there is now a empty space in small, than move the small bag back to small & store the large bag. How to generate the unique token number and move the baagage internally without changing the token number?
- catlover February 27, 2015 in India
Lookup should be in constant time complexity and insertion in minimum complexity.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersScenario : Multi Seller E-commerce Website
- Algorithmist February 26, 2015 in India
Given a list of products in a customer basket find the minimum number of seller required to deliver his order,so as to optimise shipping part.
Assuming you have already have below data
Customer orders products : P1,P2,P3,P4,P5,P6
Products and seller mapping
P1 = [1,2,3,4]
P2=[2,4,5,6]
where 1,2,3 etc denotes seller_ids.
p1| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersIf I was a marketer for a large company, tell me how I can increase the number of likes I have on my Facebook business page to 5 million?
- LeetJile February 24, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer Ideas - 0of 0 votes
AnswersYour are given two strings str1 and str2, you have to generate another unique string str3, which can only generated by these two string str1 and str2, no other string can generate that string str3. Some later point you have to retrieve back those two string str1 and str2 form that unique string str3.
- neelabhsingh February 20, 2015 in India for Hyderabad| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersYou are given an array, you have to replace each element of the array with product of the rest element. Example: {1,2,3}==> {6,3,2}
- neelabhsingh February 20, 2015 in India for Hyderabad| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersSuppose you have an array with infinite numbers, which is sorted and there may be duplicates. Find the occurrence of a number.
- MM February 20, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersHow will implement an auto complete feature? Eg: if you type clo it shows clothes etc
- MM February 20, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersSuppose there are 2 streams, which has infinite value and write a method that returns a stream that would be a combination of both the streams in a sorted form
- MM February 20, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersWrite printf method.
- Nitin Gupta February 17, 2015 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersWhich is best Merge Sort or QuickSort?
- Nitin Gupta February 17, 2015 in India
Why and How?| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersAmazon wants to implement a new backup system, in which files are stored into data tapes. This new system must follow the following 2 rules:
- anca.grigoras88 February 16, 2015 in United States
1. Never place more than two files on the same tape.
2. Files cannot be split across multiple tapes.
It's guaranteed that all tapes have the same size and that they will always be able to store the largest file.
Every time this process is executed, we already know the size of each file, and the capacity of the tapes. Having that in mind, we want to design a system that is able to count how many tapes will be required to store the backup in the most efficient way.
The parameter of your function will be a structure that will contain the file sizes and the capacity of the tapes. You must return the minimum amount of tapes required to store the files.
Example:
Input: Tape Size = 100; Files: 70, 10, 20
Output: 2| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersFind the first word in a stream in which it is not repeated in the rest of the stream. Please note that you are being provided a stream as a source for the characters. The stream is guaranteed to eventually terminate (i.e. return false from a call to the hasNext() method), though it could be very long. You will access this stream through the provided interface methods. A call to hasNext() will return whether the stream contains any more characters to process. A call to getNext() will return the next character to be processed in the stream. It is not possible to restart the stream.
- anca.grigoras88 February 16, 2015 in United States
Example:
Input: The angry dog was red. And the cat was also angry.
Output: dog
In this example, the word ‘dog’ is the first word in the stream in which it is not repeated in the stream.| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 0of 0 votes
AnswersFor a given matrix, find the maximum product of k elements. The elements can be formed from continuous 4 elements horizontally, vertically or diagonally. Eg: For k= 4, the maximum product is (6*4*7*9) from the last column,
- mailtosano February 13, 2015 in United States
1 2 0 -1 4
3 1 2 4 6
0 2 3 1 4
1 3 2 0 7
2 1 3 2 9| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
Answers(Variant of Children-Sum Problem better than O(n^2))
- Rahul Sharma February 08, 2015 in India
Given a tree, implement a function which replaces a node’s value with the sum of all its childrens’ value, considering only those children whose value is less than than the main node’s value.
Eg: input = 60->50->80->40 , output = 90->40->40->0| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding - 0of 0 votes
AnswersGiven a function rev(int i) which reverses the segment of array ar[] from 0-i, Implement a function sort() using rev().
- Rahul Sharma February 07, 2015 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 Coding