Amazon Interview Questions
- -4of 4 votes
AnswersShorten a List of Strings.
- wyu277 December 04, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 2 votes
AnswersDesign a Black-Jack poker game
- wyu277 December 04, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Object Oriented Design - 4of 4 votes
AnswersGive an 2d-characters Grid, char[][] A, and a dictionary, List<String> dict. Search all possible words in the 2d-Grid.
- wyu277 December 04, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersTake a list of integers (left to right order) and return an integer of the number of identical binary trees that can be created from the same list.
- A. December 04, 2014 in United States
Input: [10, 8, 15, 6, 9, 4, 5]
Output: 24
Input: [12, 6, 19, 15, 5]
Output: 6
Input: [44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64]
Output: 1
I wrote a brute-force 'solution', creating a binary tree for each permutation of the list (with the same root as Input list) and compared each to the binary tree from the Input list. For large input lists (length > 10), my 'solution' is useless.| Report Duplicate | Flag | PURGE
Software Engineer Intern Problem Solving Amazon Algorithm - 0of 0 votes
AnswersGiven two strings. Figure out if 2nd one is substring of 1st one. 2nd may contain wildcard characters like '*','?' etc
- Nascent December 02, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon - 0of 0 votes
AnswersWrite a recursive function to print directory structure. Two function were given isfolder() and openfolder().
- Nascent December 02, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon - 0of 0 votes
AnswersWhat data structures will you use to implement a text editor. Size of editor can be changed and you also need to save the styling information for all the text like italic, bold etc.
- Nascent December 02, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon - 1of 1 vote
Answersfinds a domino pattern for a "double-N" domino set that forms a loop / a ring using all available tiles.
- czuu December 02, 2014 in United States
for example,In a double-two domino set, with six tiles, (0 , 0) (0 , 1) (1 , 1) (1 , 2) (2 , 2) (2 , 0). So if parameter is 2, the function should return true. if no loop found, should return false.
Dominoes are small rectangular game tiles divided into two squares and embossed with dots on the top surface of the tile. You can think of dots as integers. A double-N domino set consists of (N+1)(N+2)/2 tiles, e.g. a standard double-six domino set has 28 tiles (T): one for each possible pair of values from (0.0) to (6.6) - no pair of numbers occurs more than once.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswerInput a matrics, print the elements one by one:right->left down->left->up. The 1st line is the matrics size, then follows the matrics elements. Ex:
- Cory.Xie December 01, 2014 in China
5 3
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
First loop:
starts from the top left '1';
1: to right, print 1,2,3,4,5
2: to left down, print 9,13
3: to left, print 12,11
4: to up, print 6 ('1' has been print, ignore)
Second round:
1: to right, print 7,8
2: no more elements to print
So the elements should be:
1,2,3,4,5,9,13,12,11,6,7,8| Report Duplicate | Flag | PURGE
Amazon Senior Software Development Engineer - 0of 0 votes
AnswersWe have a class as follows:
public class People{ String name; String position; String sex; ... ... public String getAttribute(String attrName){ /** * This is a generic getter method that will give you * any attribute value based on the passed attribute * Name; * for eg: getAttribute("name") => will return the * attriute(Name) value of the current object. */ } }
I now give you two List:
- Arya December 01, 2014 in United States
list1<People> friends;
list2<String> attributes;
Using the generic getter method, we have to group "friends" on "attributes". Think of this as an implementation of GROUP BY function to be implemented on objects in list1 and to be grouped on entries in list2.
eg: list2 = {sex, occupation}
So objects in list1 will be grouped such that all Male-doctors together, Female-cops together, male-cops together, etc.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 2of 2 votes
AnswersGiven an array of type:-
- anupjunagadecat November 25, 2014 in India for 11
1. Increasing
2. Decreasing.
3. Increase-Decrease
4. Decrease-Increase
Find:- 1. Type of array in minimum steps ?
2. Maximum element from array in min steps?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersYou have 81 balls. 80 balls have the same weight. 1 ball is the lightest one. What would be the minimum possible way to find the lightest ball ?
- AlgoBaba November 23, 2014 in United States
(Use Dynamic Programming)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Dynamic Programming - 2of 2 votes
AnswersGiven a large array of unsigned ints, quickly find two who's sum is 10
- JSDUDE November 22, 2014 in United States for Software Developer, Infrastructure Planning, Analysis and Optimization
Then the interviewer asked me to write test cases.
Followed by how to implement this on a distributed system, where multiple systems can read/write simultaneously on a shared cache (HINT: It is ok if you do not return the first instance)| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Arrays - 1of 1 vote
AnswersMinesweeper question: Given an n x m grid holding individual mine co-ordinates, identify all of the mine clusters. A mine cluster is the largest collection of neighboring mines.
- wyu277 November 17, 2014 in United States
Example input:
0 1 2 3
---------
0|0|1|0|1
1|0|0|1|1
2|0|0|0|0
3|1|1|0|0
Expected output:
[cluster 1] (0,1),(1,2),(1,3),(0,3)
[cluster 2] (3,0),(3,1)| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
Answers6 / \ 3 5 / \ \ 2 5 4 / \ 7 4
There are 4 leaves, hence 4 root to leaf paths:
- jeevanus November 17, 2014 in India for Hydrabad
Path Sum
6->3->2 632
6->3->5->7 6357
6->3->5->4 6354
6->5>4 654
Answer: 632+6357+6354+654=13997| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
Answers6
- jeevanus November 17, 2014 in India for Hydrabad
/ \
3 5
/ \ \
2 5 4
/ \
7 4
There are 4 leaves, hence 4 root to leaf paths:
Path Sum
6->3->2 632
6->3->5->7 6357
6->3->5->4 6354
6->5>4 654
Answer = 632 + 6357 + 6354 + 654 = 13997| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersWrite a program to make the following possible with any given tree.
- jeevanus November 17, 2014 in India for Hydrabad
6
/ \
3 5
/ \ \
2 5 4
/ \
7 4
There are 4 leaves, hence 4 root to leaf paths:
Path Sum
6->3->2 632
6->3->5->7 6357
6->3->5->4 6354
6->5>4 654
Answer = 632 + 6357 + 6354 + 654 = 13997| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswersSuggest a Data Structure to do the following opperations with time complexity O(1).
- jeevanus November 17, 2014 in India for Hydrabad
insert(int element); //insertes an element in O(1);
delete(int element); //deletes an element in O(1);
lookup(); // returns any element in random from the list at O(1);| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswersO/p the expected value of the number of people to deliver the information
- mBk November 15, 2014 in United States
I/P dependency graph
1234
1-0111
2-1000
3-1001
4-1010
o/p
2.66| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 1of 1 vote
Answersgiven a range of number 1 through N, where N >=3. you have to take an array of length 2N and place each number ( from the range 1 to N) twice. such a that the distance between two indexes of a number is equal to the number. example
- vikaskupushkar November 15, 2014 in India
N=3
( 3, 1, 2, 1, 3, 2 )
I know we can Use Backtracking but is there any other solution.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersWrite an algorithm to convert the given input string to the expected output string. The input string shall be the length of few million characters. So the output has to be updated in the same string...
- smartdiwa November 14, 2014 in India
Input String = "ABBCDEFGGGGGGGGHHXX..<20 more X>..XYY..."
Expected output = "A1B2C1D1E1F1G8H2X23Y2..."
Note: The count of each character has to be appended with the same character in the output string| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersIn basket ball game for a player to win a game
- Aspire November 13, 2014 in United States
challenge 1) 2 out of 3 throws should be basket
challenge 2) 4 out of 6 throws should be basket
which challenge should the player choose so that he might have better chance of winning the game?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 1of 1 vote
AnswersIn basket ball game for a player to win a game
- Aspire November 13, 2014 in United States
challenge 1) 2 out of 3 throws should be basket
challenge 2) 5 out of 8 throws should be basket
which challenge should the player choose so that he might have better chance of winning the game?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Probability - 1of 1 vote
Answersgiven expression with operands and operators (OR , AND , X-OR) , in how many ways can u evaluate the expression to true, by grouping in different ways? Operands are only true and false.
- amidala.shiva November 02, 2014 in India
for example true & false | true ^ false can be grouped to true & ((false | true) ^ false) and so on..
the following wiki of the above question
http://en.wikipedia.org/wiki/Boolean_satisfiability_problem| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
Answerscalculate the summary statistics for a fleet of hosts. Each host has a fixed number of slots in which virtual instances can run. Each host can only run instances of a particular type, e.g. M1, M2, or M3. You are provided with the file “FleetState.txt” that contains the state of the fleet. Each line in the file represents a single host in the following comma-separated format:
- Algo October 31, 2014 in -
<HostID>,<InstanceType>,<N>,<Slot1State>,<Slot2State>,…,<SlotNState>
where
<HostID> is an integer
<InstanceType> can be M1, M2, or M3
<N> is the total number of slots on the machine
<SlotjState> is 0 if slot j is empty and 1 if it is occupied by an instance
Write a program that loads the state of the fleet from the input file “FleetState.txt” and then computes and writes out the following summary statistics to the output file “Statistics.txt”:
For each instance type, the count of empty hosts (all slots empty)
For each instance type, the count of full hosts (all slots filled)
For each instance type, the count of the most filled hosts (having the smallest number of empty slots > 0). Both the host count and number of empty slots must be written out in that order.
The output file must have the following format:
EMPTY: M1=<count>; M2=<count>; M3=<count>;
FULL: M1=<count>; M2=<count>; M3=<count>;
MOST FILLED: M1=<count>,<empty slots>; M2=<count>,<empty slots>; M3=<count>,<empty slots>;
What is the best way to solve this problem?| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
Answerscalculate the summary statistics for a fleet of hosts. Each host has a fixed number of slots in which virtual instances can run. Each host can only run instances of a particular type, e.g. M1, M2, or M3. You are provided with the file “FleetState.txt” that contains the state of the fleet. Each line in the file represents a single host in the following comma-separated format:
- Algo October 31, 2014 in -
<HostID>,<InstanceType>,<N>,<Slot1State>,<Slot2State>,…,<SlotNState>
where
<HostID> is an integer
<InstanceType> can be M1, M2, or M3
<N> is the total number of slots on the machine
<SlotjState> is 0 if slot j is empty and 1 if it is occupied by an instance
Write a program that loads the state of the fleet from the input file “FleetState.txt” and then computes and writes out the following summary statistics to the output file “Statistics.txt”:
For each instance type, the count of empty hosts (all slots empty)
For each instance type, the count of full hosts (all slots filled)
For each instance type, the count of the most filled hosts (having the smallest number of empty slots > 0). Both the host count and number of empty slots must be written out in that order.
The output file must have the following format:
EMPTY: M1=<count>; M2=<count>; M3=<count>;
FULL: M1=<count>; M2=<count>; M3=<count>;
MOST FILLED: M1=<count>,<empty slots>; M2=<count>,<empty slots>; M3=<count>,<empty slots>;
what is the best way to solve it?| Report Duplicate | Flag | PURGE
Amazon SDE1 - 1of 3 votes
Answers== Question ==
- zhaolixi1991 October 30, 2014 in United States
Given a list of TestResult, where each result contains a test score, a student ID and a date, figure out the students' final scores. A final score is the average of a student's top 5 scores.
Here is a sample of the list of TestResult:
50 JACK 5/14/2013
89 ALICE 3/25/2012
70 BOBBY 12/7/2010
60 JACK 8/9/2013
99 MIKE 9/11/2011
100 JOHN 7/4/2011
38 JACK 1/28/2014
46 JACK 11/15/2012
<... more ...>
struct TestResult {
score,
student_id,
date,
}| Report Duplicate | Flag | PURGE
Amazon Intern Algorithm - 0of 0 votes
AnswersGiven ~300k words with an average length of 7 in a file.
- JSDUDE October 27, 2014 in United States
All words are dictionary correct words.
Print all the anagrams that are present in this list of words without repeating them.
E.g. if the list has:
ACT
BAT
CAT
TAB
TAC
print:
ACT, CAT, TAC
BAT, TAB| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Data Structures - -1of 1 vote
AnswersDesign the algorithm and the system for a WebCrawler.
- JSDUDE October 27, 2014 in United States
The webcralwler will be provided millions of URLs. The webpage will be downloaded and then parsed for more URLs. If more URLs are found then they should also be downloaded and parsed.
He was interested in:
1. Scale to handle millions of URLs
2. What are the bottle necks in the system? How will you resolve them| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Object Oriented Design