Amazon Interview Questions
- 0of 4 votes
AnswersWrite code to reconstruct the tree from given any 2 traversals.Do it iteratively.
- nishu August 14, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - -3of 3 votes
AnswersRequirements:
- MrA August 07, 2013 in United States
1>client should be able to create shapes like circle, square , rectangle..etc,. Also framework should be able to add some more shapes later.
2> client should be able to calculate areas of each shapes
3> should have collection where all shapes are stored and should be able to sort on the area of the shapes| Report Duplicate | Flag | PURGE
Amazon SDE1 Object Oriented Design - 0of 0 votes
Answersn1 pairs of “{} ” brackets
- nishu August 03, 2013 in India
n2 pairs of “[] ” brackets
n3 pairs of “() ” brackets
find the all valid combinations of all the pairs.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - -6of 6 votes
AnswersThere are three persons A,B,C .A shots the target 6 times out of 7 shots .B shots 4 out of 5 shots .Then what is the probability of hitting the target twice when 2 persons are selected at random.
- siddharthjain July 29, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Probability - 0of 0 votes
Answerswrite a code to find the equilibrium position of the array.
- gaurav.2897 July 25, 2013 in India
given an array: 3,-3,8,6,-1,-5
equilibrium position should be 2(element 8) sum of lower index(3+-3)=sum of higher index(6+(-1)+(-5))| Report Duplicate | Flag | PURGE
Amazon SDE1 C - 3of 5 votes
AnswersThere are N(0 to N-1) players each having at Max 'M' (0 to M-1) number of followers. You have to select minimum number of players so that the total followers must be equal to a given number 'K'.
I/P would be like,
first line contain N, M, K followed by N lines containing string of 0 or 1 s.t. for i'th line if j'th char is 1 it means j'th person follows player 'i'
For. eg.
- P3A July 18, 2013 in India3 6 5 111100 000100 000010 ans=2 ( select 0th and 2nd )
| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 11of 13 votes
AnswersThere are some glasses with equal volume 1 litre. The glasses kept as follows
1 2 3 4 5 6 7 8 9 10
You can put water to only top glass. If you put more than 1 litre water to 1st glass, water overflow and fill equally both 2nd and 3rd glass. Glass 5 will get water from both 2nd glass and 3rd glass and so on..
- Vin July 17, 2013 in India
If you have X litre of water and you put that water in top glass, so tell me how much water contained by jth glass in ith row.
Example. If you will put 2 litre on top.
1st – 1 litre
2nd – 1/2 litre
3rd - 1/| Report Duplicate | Flag | PURGE
Amazon SDE1 - 2of 2 votes
AnswersWAP to create a mirror of a binary tree. Extend the code or write a new code if not possible to do mirroring at alternate levels . Here in the second part , if the two trees are placed in front of each other , then odd levels should be exact mirror as a whole and even levels should be exactly same . Then write the iterative version for the above codes.
- Kavish Dwivedi July 15, 2013 in India for Bangalore| Report Duplicate | Flag | PURGE
Amazon SDE1 Trees and Graphs - 22of 22 votes
AnswersYou are given an array of n integers which can contain integers from 1 to n only . Some elements can be repeated multiple times and some other elements can be absent from the array . Write a running code on paper which takes O(1) space apart from the input array and O(n) time to print which elements are not present in the array and the count of every element which is there in the array along with the element number .
- Kavish Dwivedi July 15, 2013 in India for Bangalore
NOTE: The array isn't necessarily sorted.| Report Duplicate | Flag | PURGE
Amazon SDE1 Arrays - 0of 4 votes
AnswersWrite a method in your preferred language that given an array of n points on a plane specified by their (x,y) coordinates, and an angular size α, returns the direction β at which a beam of size α centered at the origin of the coordinate system would enclose the most number of points from the array. The direction of the beam can be represented by an angle β as shown in the illustration below.
- shylaja23 July 13, 2013 in United States
Tip: The function arctan(y/x) returns the angle of a point.
In the illustration below, the blue dots represent points from the array and the grey beam represents the beam of size α pointed in a direction β where it happens to enclose three points.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 4 votes
AnswersConstruct a BST from inorder and preorder traversal string. Write code for it.
- yolo July 11, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Trees and Graphs - -11of 11 votes
AnswersGiven a tree, verify if it contains a subtree.
- yolo July 11, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Trees and Graphs - 0of 2 votes
AnswersGiven a maze that contains floor plan with rooms.
- yolo July 11, 2013 in India
For example, consider a n*m matrix where each block represent a room.
You can move up-down and left-right from one room to another. But there are some rooms where there no door to one or more side of the wall.
some rooms are bathrooms.
Given a room location, return the nearest bathroom.
Start by writing method signature. Interviewer said that :)
It was bar raiser round.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 5of 7 votes
AnswersDelete last node from the linked list. First node pointer is not given.
- yolo July 11, 2013 in India
I told him its not possible in conventional linked list.
He asked me what if we can add some more data in node.
Data should not be a pointer to previous node i.e., it should still be singly linked list.| Report Duplicate | Flag | PURGE
Amazon SDE1 Linked Lists - 0of 0 votes
AnswersGiven function List friendList(Person p) which will give all freinds list of that person. Write a function such that printConnectedLeastFriends(Person A, Person B); if none of the friends found connected print "NONE";
- MrA July 07, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersGiven a word consisting of letters, different words can be formed using all the letters in the word. Find the rank of input word in sorted list of all possible words.
- engineer July 07, 2013 in United States
Eg.
ABAB = 2
QUESTION = 24572
Program should use no more than 1GB memory and run within 500 milliseconds. Maximum input length = 25 and input word will contain atleast 2 different letters.| Report Duplicate | Flag | PURGE
Amazon SDE1 - 1of 1 vote
AnswersString [] [] matrix = {{"A","N", "L", "Y", "S"},{"I", "S", "D", "E", "S"},{"I", "G", "N", "D", "E"}};
- gohilumesh July 05, 2013 in United States
// 2. Given a word "DES"
// 3. Write a program to find the occurences of this word "DES". Letters must be next to each other in the matric.
// 4. "Next" means: left, right, up, down, left down, right down, upper left, upper right
// 5.. For example: S at (1,1): A, N, L, D, N, G, I, I are next to S at (1,1)
Required output
// // D - [1, 2], E - [1, 3], S- [1, 4]
// D - [1, 2], E - [1, 3], S- [0, 4]
// D - [2, 3], E - [2, 4], S - [1, 4]
// D - [2, 3], E - [1, 3], S - [0, 4]
// D - [2, 3], E - [1, 3], S - [1, 4]| Report Duplicate | Flag | PURGE
Amazon SDE1 Matrix - 2of 2 votes
AnswersHow can we implement spell checker.
- rapirapp July 04, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Data Structures - 0of 0 votes
AnswersDesign a tree, in which a node can have unlimited children and write a code to print each level in separate level.
- grave June 27, 2013 in India
(As the number of children is large we cant store them in queue.Can we do it without extra space ?)| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersFind the largest k elements from a large file?
- grave June 27, 2013 in India
You dont have RAM to store even k elements.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersGiven an array of positive integers, find the max no that can be formed by any permutation of the arrangement.
- Vin June 26, 2013 in India
input {21,9,23}, output = 92321| Report Duplicate | Flag | PURGE
Amazon SDE1 - 1of 1 vote
AnswersGiven a string dind the largest substring which is palindrome.
- anag June 26, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 5of 5 votes
Answers100 doors are closed , In first pass i open all of them , in 2nd pass i toggle every 2nd door , in 3rd pass i toggle every 3rd door , i continue it till 100th pass .. find all the doors that will remain open after 100 passes.
- anag June 26, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Brain Teasers - 5of 5 votes
Answersfind the sum of all 4 digit numbers formed from 1 , 2, 3, 4 whithout rep .
- anag June 26, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Brain Teasers - 1of 1 vote
AnswersTwo files containing large number, one in each. You have only fopen(), int read(fp), fclose(), fwrite(). Add these two numbers and write in third file with the help of given functions only.
- grave June 23, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm C# C++ Coding Data Structures