Amazon Interview  Set 28
Hi, I was recently interviewed for SDE1 position for Amazon, Hyderabad but was not able to make it through. Although I wasn’t selected but it was a good experience and GeeksforGeeks has been very helpful.
Following were interview questions
I had one written round and one telephonic round before 4 inface interviews in Hyderabad.
Round 1 (Written):
There were four questions which had to be submitted in a time span of two hours. Questions were:
1. Given a character string, display the characters that appear more than once in that string.
2. Rotate a matrix 90 degrees to right
3. Convert a BST to DLL.
4. Find kth largest element in a given BST.
Round 2 (Telephonic):
1. First question was to get two numbers from a BST whose sum was equal to k. I answered it using a preorder traversal to get a sorted array and than starting two index from both ends to find if two elements with sum as k exist or not. He than asked if it can be solved without using an array or extra space. I tried solving it by traversing from two ends of the tree in eoder and reverse preorder fashion and it took some time to code. Dry run of the code seemed to be right but I wasnt sure. Anyways the best way of not using extra space can be to convert tree to DLL (in space) and use the same technique as used on array.
2. For second question I was asked if I had heard the question before or not. Question was that a matrix is given with its rows and columns sorted and an element is to be searched in that matrix. I had heard the question before but had not solved it and told the same to the interviewer. After thinking for a while I could get an algo by starting at the rightmost element of the first row. If element if bigger we move down or else we move right. The solution was fine but he doubted that I had solved it earlier.
3. He asked to write a program of finding the square root of a number without using library functions. I had done it before and told him the same. I used Newtonrapson method to get the solution but he wanted it through something on the lines of binary search. I almost got the solution but may be I was running out of time so he dropped the question there only and asked me to dictate the solution of 2nd problem.
Two days later I got a call that I have cleared my telephonic round and have to be present in Hyderabad for further rounds(four). Arrangements done my Amazon and I appeared for the further rounds on 27/4/2013 in their Hyderabad office.
Onsite:
Round 1 (Technical):
1. First question was to find the vertical sum of a binary tree. I told him the solution using and array/hash. Whenever we move left we decremented the index while moving right we increment the index. The solution looked fine to him but he wasn’t very comfortable with negative indexing. So he asked for another solution using doubly linked list. Initially I wasn’t getting it but when he gave some hint I was bale to solve it but it took some time to cover edge cases. With the final solution he looked convinced.
2. Next question was to have Stack operations of Push, Pop, and FindMax in O(1) time. I started doing this using only one index of max variable but than I realised I needed max index at all levels so gave him a solution using two stacks. One having the element and the other having the corresponding max index. He looked convinced with the solution.
Round 2 (Technical):
1. In second round there were two interviewers and coincidentally one of them was the same guy who took my telephonic interview. First question was related on how to chose the ‘related’ items list whenever a product is displayed on Amazon website. the problem was to find the least related product for a given product. Initially I answered using nary tree but told him that we would have duplicate entries. He asked for optimized solution so I suggested using adjancylist nut finally realized that it can be solved using graphs. They were convinced and asked to code. I solved it using a Queue so while traversing a matrix we pushed in the elements in the queue with their level of relation. They were convinced with the solution.
2. Second question was to delete an element from doubly linked list. I solved it but missed out on and edge case where the element to be deleted is not present in the list. I added that check later.
3. Third was that for a given BST invert the signs of the elements and finally have a new BST. It clicked my mind that after sign inversion it will be a mirror tree and gave the solution for the same.
Till this time feedback looked fine.
Round 3 (TechnicalManagerial):
1. The next interviewer was senior guy and asked me about my work. Explained him in detail.
2. Later he asked me that for a given binary tree having three address fields i.e. left, right and bfs successor, left and right fields are filled and the successor field is to be filled. I solved it using level order traversal with a queue but he wanted solution without using extra space. I was taking time to solve it when he gave hint about keeping track of the parent. After this hint I was able to solve it with few conditions missing but with his intervention I was able to give a working code (as looked to him and me).
Round 4 (TechnicalManagerial):
1. There were two interviewers. First question was tell me about yourself and your work.
2. Given a m*n matrix, we need to find the number of ways by which a bot can reach the (m1,n1) block if bot can move only right and down while starting from (0,0). I gave him a solution using DP. Build the recursion tree showing the final solution. He didn’t ask to code but asked to finds the recurrence relation. I got stuck I don’t know why. I guess this was the start of decline. he gave some hints and I was finally able to write it, still.
3. For a given binary tree and a key, prune the tree with all the paths (root to leaf) that have sum less than or equal to k. I was able to solve it with some hint. The solution looked convincing.
Four days later I got a mail stating that “Unfortunately, we are unable to take your candidature further, at the moment. However, your credentials are extremely impressive and we wish to retain your details on our active database. We shall get back to you as soon as another similar opportunity opens up.”

This article is compiled by Rohit. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Recommended Posts:
 Amazon Interview Experience SDE1  AmazonWOW 2020
 Amazon SDE1 Interview Experience  Amazon WOW2020
 Amazon Interview Experience (Telephonic Interview)
 Amazon Interview Experience  Set 249 (Telephonic Interview)
 Amazon Interview Experience  Set 180 (Telephonic Interview )
 Amazon Interview SDE 1 Interview Experience
 Amazon Interview  Set 38 (SDEI)
 Amazon Interview  Set 39 (SDE)
 Amazon Interview  Set 34
 Amazon Interview  Set 35
 Amazon Interview  Set 19
 Amazon Interview  Set 37
 Amazon Interview  Set 36
 Amazon Interview  Set 89
 Amazon Interview  Set 93