Some time back I went through an interview for Amazon.com for SDE-1 role, and here is my experience to help other aspirants :
Written – Pen & Paper Rounds
Had to write production level code in any programming language of my choice, covering all the edge cases, and clearly mentioning the complexity of my code.
- Lowest common ancestor in Binary search tree
- Remove minimum number of characters so that two strings become anagram
- Given an array, print the Next Just Greater Element for every element. The Next just greater Element for an element x is the just greater element on the right side of x in array. Return the same element if there is no greater element present on right side, or if same element is present again on right side (in case of duplicates)
For e.g. given input array : 3,5,8,4,2,6,3 output should be : 3,6,8,6,3,6,6
Solution: neveropen Link
Solved it using Binary search tree
Face to Face Rounds?
Interviewers were very very helpful, and were focused on approach, they will ask basic brute force solution first, then an optimum solution, after that they may increase the complexity of problem a little bit, and if you are able to explain your approach satisfactorily, then will ask you to write production level code in any programming language of your choice, covering all edge cases using pen and paper :
- Find an element in an unsorted array such that all left elements are smaller and all right elements are greater.
Solution: neveropen Link
O(n) time complexity solution is required. - Find kth smallest element in row wise column wise sorted matrix. Discussed both min heap and max heap approach with complexity of both.
Solution: neveropen Link - What if there are duplicate elements in matrix, and we have to consider all duplicate element as one position, i.e. if matrix contains elements like 3,6,4,3,5,4,7 then
1st smallest element is 3
2nd smallest element is 4
3rd smallest element is 5
4th smallest element is 6, irrespective of there occurrence
I asked if I can use hashing, but he was looking something with less space complexity, was not able to answer this particular thing further. - Level order traversal in spiral form
- Find the maximum difference between any combination of child and parent node in a given binary tree. Here child node can be any level below parent node, but should be in the same sub tree starting from parent node. solved using recursion, bottom up approach, returning the maximum difference and minimum node value till current node, to upper node at every level.
Solution: neveropen Link - Detailed discussion about project, something new which I have designed, why this, why not this etc, how my team work, complete process, my individual role, responsibility and contribution. Do you have bugs in code, how you correct. Have any bug from your code reached production. What you do outside of work, do you have any open source contribution, etc.
- Given any two nodes in a binary tree, find the path from 1st node to another, and tell if the path is a straight line, or there are turns on the line, find number of turns.
Solution: neveropen Link - Detailed discussion about java hashmap, hashset, its internal working and its complexity.
- Lots of behavioural questions like, most complex thing done, how you did it, what challenges you faced, negative feedback you received, how you improved, and many more cross questions.
Advice to fellow members preparing for something like Amazon :
- first get good understanding of basic data structure concepts, can refer geeksforgeeks.org section wise or any book like Narasimha Karamunchi (I referred this book), don’t just read, but implement things.
- Read book like Cracking The Coding Interview to learn how to answer behavioural questions. These questions are very limited, but are must for amazon.
- Practice and solve last 40 amazon interview experience from practice.geeksforgeeks.org
I hope this information will be helpful to all of you, wish you all the very very best.
If you like neveropen and would like to contribute, you can also write an article and mail your article to review-team@geeksforgeeks.org. See your article appearing on the neveropen main page and help other Geeks.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!