Recently I attended interview at Amazon for SDE 1 profile.
Round 1 (Written):
3 questions were given and I was asked to write the executable code in any language.
- Check whether the tree is BST. (O(n) time).
- Check whether the Linked List is Palindrome. (O(1) space).
- One array (Array 1) of size m with m sorted elements and another array (Array 2) of size (m + n) with n sorted elements, you have to put all the elements from both the arrays in Array 2 in sorted order. (O(1) auxiliary space and O(m + n) time).
Round 2 (F2F):
- Given a stack of integers of size n, you have to sort it using only push and pop operations (you are not allowed to copy the numbers in auxiliary array and sort it and then push back in array). (I gave O(n^2) approach and O(1) auxiliary space).
- Stepping on stairs: A valid move is defined as either a single step or 2 steps. Starting from 1st stair you have to reach nth stair in minimum valid moves. I gave dp approach then rolled down it to Fibonacci formula which can be solved in O(log(n)) time using Matrix Exponentiation.
- Stepping numbers: A stepping number is defined as a number in which the absolute difference between the consecutive digits is not greater than 1, A stepping number cannot be a single digit number. You have to find the number of stepping numbers between n1 and n2 where n2 > n1 and n2, n1 > 0. First I gave brute force approach i.e. traverse from n1 to n2 and print i if i is a stepping number. They asked me to optimize it, after a little while I came up with BFS solution, where a node in graph (directed) represents a number and nodes directly connected to it have one more digit appended at the end. Stop when number dequeued from the queue is greater than n2.
- Iterative version of Tower of Hanoi. I gave stack version of TOH. Since recursion uses recursion stack. I removed recursion and used stack to imitate recursion instead. They were satisfied with the solution.
Round 3 (F2F):
- In any point of time print the first non-repeating number in a stream of numbers. It took me quite a while and after little brainstorming I came up with solution using DLL and map.
- Delete node in a BST. I had forgotten how it was done so again I had to think hard, realized that deleted node must be replaced with its inorder successor to maintain the BST property and coded the solution.
- This was the most exciting round. They seemed happy with my approach.
Round 4 (Design Round):
- Design a Parking Lot.
- Create queue using stack.
- Discussion on all the OS scheduling Algorithms.
- How to implement SRTFS (preemptive SJF).
- Discussion on Inter Process Communication : Shared Memory and Sockets.
- Why sockets are preferred over Shared Memory.
- Where shared memory is stored (in user space or kernel space) ? and why ?
Round 5(Hiring Manager Round):
- General Discussion.
- Infix to Postfix conversion.
- Return a maximum length sequence containing consecutive numbers from a binary tree. i.e.
90 / \ 1 66 / \ 2 67 / \ / 5 4 68 / \ 99 100
Consecutive sequence of maximum length: [66, 67, 68] of length 3.
I had the hunch but was not able to code it at first, so he asked me to do it later then after some discussion, i was given 15 min to complete it and finally in those 15 min it clicked and I managed to do it.
- Practice coding on paper, try to do write clean code without overwriting.
- Brush up important concepts of OS.
- They concentrated more upon the thought process to reach the final solution. So think loudly and you will receive hints ;).
- Keep calm and remain confident.
Thank you Geeksforgeeks !!!
If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
- Amazon Interview Experience | SDE-1 offcampus
- Amazon Interview Experience | Set 167 (SDE I for 1 year 6 months experience)
- Amazon Interview Experience | Set 242 (1 Year Experience)
- Amazon Interview Experience | Set 391 (SDE-2, 5.5 years Experience)
- Amazon Interview Experience | Set 243 (2.5 Years Experience)
- Amazon Interview Experience | Set 241 (1.5 years experience)
- Amazon Interview Experience | 401 (3+Years Experience for SDE II)
- Amazon Interview Experience | Set 248 (4.8 Yrs Experience for SDE II)
- Amazon Interview Experience | Set 222
- Amazon Interview Experience | Set 357 (For SDE II)
- Amazon Interview Experience | Set 427 (SDE-2)
- Amazon Interview Experience | Set 165 (For SDE I)
- Amazon Interview Experience | Set 353 (For SDE-2)
- Amazon Interview Experience | Set 314 (For FTE)
- Amazon Interview Experience | Set 234 (For SDE-II)