# Amazon Interview Experience SDE ll

Thanks to my friend who told me all this.w

### Round 1:

Trapping Rain Water :Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.

Print left the view of a binary tree.
Discussion : give two approaches one with DFS and other with level order traversal.
He asked to compare two approaches and implement the efficient one. DFS is the efficient one because in level order, you need to store all the nodes at each level, some of them may not be a part of the left view of BT.

### Round 2:

Find the sum of n elements after a kth smallest element in BST. Tree is very large, you are
not allowed to traverse the tree.
Discussion : Since the array traversal is not allowed so one need to do some preprocessing over the tree, something like storing the sum of all its predecessor nodes.For finding kth smallest element, use order statistics approach:

Given a sorted array which has been rotated n number of times. Find the value of n. It is similar to below post where you need to find only the pivot element. If you have the Index of pivot element, you can get the number of times the array is rotated.

### Round 3:

Count ways to reach nth stair.It is similar to the fibonacci series. Interviewer asked various ways to implement the same -Recursion, 1-D array, with 3 variables and complexity of each.
Design recommendation engine.

It’s like an auto suggestion. Give the trie approach. The interviewer seemed fine with this approach and asked to write full code with time and space complexities. Implementation of Tries

### Round 4(Managerial Round – Over video call)

Current work
Which project you liked working the most.
Any idea/technology suggested by you to your team which then got implemented and worked out.
Any case when you had to work out of your comfort zone.
What do you do to enhance your technical knowledge apart from your project work.
And many more.

### Round 5(Final Round – Telephonic)

Initially, They will ask questions about the work done, the projects the person did and some managerial questions.
Ques : Print all the non-repeating words out of two given sentences.
Eg. Statement 1: I have a blue pen.
Statement 2: I got a red pen.
Output : have blue got red
Discussion : Suggested the hashing approach. The interviewer asked to implement the same.