# Amazon Interview Questions – Set 5

I got interviewed for Amazon Hyderabad for SDE1 position . It was for e-commerce platform team.
I want to share my experience so that it can help others. I have 7 months of experience but the vacancy was for 1+ year exp. Guys all the logistics were arranged by Amazon (Including flight tickets+Hotelstay+cab+lunch and dinner). It was an amazing experience.

Round 1(Online):
Q1. 18 questions in 20 minutes (probability, Os ,DSA,c).
Q2. In second section 2 programming questions in 30 minutes.(Pruning a binary tree , Cutting a rod so that we can get optimal benefit ).

After 2 days HR called me for 3 F2F interviews.

Round 2:
Q1. Given array of stock prices get the date of selling and buying so that profit is maximum.
Discussed various approaches Brute force ,Using heaps, Divide and conquer and optimal solution.
For each approach I wrote the code on white paper and they told to trace it out with example. I have to write production level code with all corner cases.

Round 3:
Q1. Print a matrix diagonally .
I was told to write the code as question was quite easy . After that we moved on.
Q2.Frog can jump 1 or 2 steps write the code to find out number of ways to go up to n steps.
Discussed the complexity of it with mathematical proof.
Q3. Check for balancing of parenthesis using divide and conquer. Didn’t ask for code just wanted the approach. I solved it with stack. But he just wanted Divide and conquer.
After thinking for 15 minutes and observing several examples.
I came up with an algo and bingo(According to me whole 5 rounds were quite easy and that question made the difference for me).
Q4. There is a dictionary of billion words and there is one method provided
String getWord(int index); We can give it index and it will return the String on that index .
Now word is given to us we have to find out its index. O(logn) solution was required.
Q5. After that he moved to Oops concepts asked about abstract classes and interfaces.
Also asked when to use interfaces .
After that we had discussion on volatile keyword(Asked for program which can show its behavior ) and synchronization.
Q6. He told me if there is a class and if we want to use only 3 methods of it so in that case we should use inheritance or not. Asked for other better options.

Round 4 (With Hiring manager):

Q1. Why are you leaving your company so early.
Q2. Discussion about project in company and about my college projects as well(It was a deep discussion and I think it can throw us out if we don’t give proper answers).
Q3. Replace each node in BST with sum of its greater nodes. I solved it quite easily after that he applied various constraints on it(around 3 or 4). So the problem became quite hard. But after thinking about it solved it.
He was happy after the solutions provided by me.
4. After that he discussed about n-ary tree and getting the LCA in n-ary tree of n nodes.(Wrote the code for it and discussed complexity).
6. How to make a file mutually exclusive on a shared file system.

After one week HR called me that I have one more round with s/w developer manager so I went back to HYD.

Round 5:
Q2. Negative and positive things in you.
Q4. Tell me a situation in your current company when you had a failure in doing a task and What you learnt from it.
Q5. Replace every element in array with its closest maximum element in right.
As amortized analysis was involved he asked for mathematical proof.
Q6. Asked to design distributed Hashtable . Discussed pros and cons.
Q7. How will you resolve conflicts with your manager.
Q8. How will you resolve conflicts with your team mates.

After that I came back to Pune. I went through a lot of thinking.

After two days I got a call from HR that feedback is very positive and all the interviewers want you in their team. and I got an offer.

Books I used :
1. Coreman(Intro to algos)
2. Skiena(Algo design)
3. Narasimha Karumanchi
4.Peeling design patterns.