Getting help from the Leetcode community for a long time. I just wanted to give something back as well. :)
I gave an amazon interview last week and wanted to share my experience. I had given an online test prior to the onsites some time back but i do not remember the questions that well. Two weeks later, I was asked to come for onsites.
Pointers before discussing about onsites questions:
- Every round was a coding round alongside LP round.
- The rounds also consisted of a few questions asked in relation to core subjects like Operating Systems, DBMS, Networks etc.
- Each round had atleast two coding questions asked.
- Each round went on for atleast an hour in my case
Round 1: I was asked two questions. Both being from leetcode and of medium difficulty. Topics begin Trees and Arrays.
- Given a binary tree and a sum. Find if there exists a path from root to leaf with sum of node values to be equal to the target value given.- https://leetcode.com/problems/path-sum/
I was able to come up with an O(n) solution and was able to code up pretty fast.
- Trapping rainwater problem-https://leetcode.com/problems/trapping-rain-water/
This is a pretty well known problem and I did remember it doing a long time back. I had a discussion with the interviewer and was able to come up with an O(n) time and space solution. We went further discussing on STLs in C++ and couple of other topics.
- Apart from this there was a resume discussion and couple of LP questions as well.
Round 2: Questions again were from leetcode. The topics asked were from stacks and heaps.
- Given a stream of integers, find the median of numbers at any point.
I had never seen this question before hand, but first come up with a brute-force approach, but with a couple of hints from the interviewer I came up with a heap solution there. Later saw that this question is pretty well known leetcode-hard question.
https://leetcode.com/problems/find-median-from-data-stream/
- Perform Push, Pop and Get_Min in O(1) complexity.
This question was easy and I had a good discussion with the interviewer about different approaches.
- Here I was asked questions from OOPS and Networking. I was able to answer question from OOPS but unable to answer the questions from networking.
Round 3: I was asked three questions in this round. I was asked mostly DP and one Heap question in this round.
- The question was given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.
I had never seen this question before and DP being a weak spot for me, I was unable to come up with a DP solution of this problem. I gave a recursive approach but was unable to further optimise it. Later found out that this question was available on leetcode as well.
https://leetcode.com/problems/interleaving-string/
- The next question was again from DP, and I had seen the question before. The question was Decode Ways-https://leetcode.com/problems/decode-ways/
I was able to come up with both a tabularised and a recursive approach for this problem. I had a good amount of discussion with the interviewer on this question.
- Later on, I was asked the question on K-frequent words from a stream of words incoming. I was able to come up with a brute force solution and then the interviewer asked me to code it up. Post that we had a discussion on everything in relation to designing of the hashmap and priority queues which was in relation to the question.
- The interviewer also asked a couple of DBMS questions like ACID properties and some SQL queries.
Round 4: This was the last round. I was asked two questions here. I bombed this interview pretty badly, even though I was able to code it up but I took a lot of time even though the questions weren't that tough.
- I was asked a couple of LP questions and things from my resume. Even though I was able to answer LP questions comfortably, I had not revised my resume projects that thoroughly and the interviewer went in depth analysis of my projects where I was unable to answer a couple of questions mainly because I hadn't revised.
- It was a graph problem to be done using minheaps. I coded up that solution pretty fast. We had a discussion on minheaps and I was asked to write a code for minheap extraction which was the part where I made a mistake. I got confused in one point and I took a lot of time thinking and kept getting confused further. After sometime, the interviewer started getting slighly frustrated gave me a hint from which I was able to code up the question. I got so nervous and then gave the incorrect complexity analysis of it.
- The second question was Word ladder - https://leetcode.com/problems/word-ladder/
I gave the brute force analysis and since I was nervous from the prior mistake I ended up again giving incorrect time complexity analysis. The interviewer helped me a bit further and I was able to come up with a optimised solution but since I had already taken a lot of time, I was unable to code that up.
Mistakes that I actually learnt from after giving the inteviews:
- Revise everything on your resume that you think can be asked from you. Getting rejected just because you weren't able to answer something you had done a long time back sucks badly.
- Even if you have made mistakes in one round or asked too many hints don't let that boggle you down. Consider every question a new opportunity in that interview irrespective of how the previous one went.
- Get your time complexity analysis right. I realised that this concept still is an extremly weak portion of mine.
- Interviews are luck based, but the only thing you can do is give your best shot so that you never have regret of not trying.
- Rejections happen all the time and I'm pretty sure everyone here must have faced that atleast once. Just take it as a learning experience and move forward. Maybe that company wasn't for you right now, but that doesn't mean it will never be in the future.
I hope this experience is helpful to anyone who is trying in Amazon and I hope you do get in. All the best :)