I gave an interview with Amazon in the start of the year. Here are the questions I faced:
First Round was a Written Test.
Q1) Reverse words in a sentence
Q2) Print 2D array in Spiral Order
Q3) Remove all nodes with the given value in a linked list:
LinkList removeValues(LinkList Head, ValueObject value){
}
Q4) Find the first non-repeating character in a word.
Second round was a F2F technical discussion:
Given a Tree:
What is the order of nodes when you parse the tree as:
1) Breadth First:
Ans: 1 2 3 4 5 6 7 8 9
2) Reverse Breadth First
Ans: 7 8 9 4 5 6 2 3 1
3) Zig Zag
Ans: 7 8 9 6 5 4 2 3 1
He asked many followup questions on Tree Parsing, searching, Collections, LinkedLists etc.
Few of them were like:
While doing the above Breadth First, etc, How would you do it if you were to do only using:
1) Only two Queues
2) Only 1 Queue and 1 Stack
3) Only 2 Stacks
Third Round:
He gave me pattern like:
First Round was a Written Test.
Q1) Reverse words in a sentence
Q2) Print 2D array in Spiral Order
Q3) Remove all nodes with the given value in a linked list:
LinkList removeValues(LinkList Head, ValueObject value){
}
Q4) Find the first non-repeating character in a word.
Second round was a F2F technical discussion:
Given a Tree:
What is the order of nodes when you parse the tree as:
1) Breadth First:
Ans: 1 2 3 4 5 6 7 8 9
2) Reverse Breadth First
Ans: 7 8 9 4 5 6 2 3 1
3) Zig Zag
Ans: 7 8 9 6 5 4 2 3 1
He asked many followup questions on Tree Parsing, searching, Collections, LinkedLists etc.
Few of them were like:
While doing the above Breadth First, etc, How would you do it if you were to do only using:
1) Only two Queues
2) Only 1 Queue and 1 Stack
3) Only 2 Stacks
Third Round:
He gave me pattern like:
Write a recursive program to print similar pattern shown below given any number: Pattern 1: number: 5 ----- - -- - --- - -- - ---- - -- - --- - -- - ----- Pattern 2: number: 4 ---- - -- - --- - -- - ---- Pattern 3: number: 6 ------ - -- - --- - -- - ---- - -- - ----- - -- - ---- - -- - --- - -- - ------
If you observe the patterns, given a number the first and last lines will have so many number of dashes. the the common pattern occurs between dash lines: - -- - Then after the first line, start with 3 dashes and go till (n-1) then go back till 3.