InterviewNoodle

One stop learning portal for your next coding and system design interview.

Follow publication

Amazon SDE Interview Experience (On Campus)

--

Amazon visited our IIITB campus in 2017 for hiring both the intern and full-time positions. I ended up with an offer and I am sharing the full details of the interview process that I went through.

Amazon Hiring Process

The campus hiring process had an initial screening round on Hackerrank. It is then followed by four F2F technical interview rounds for the candidates who are shortlisted from the initial screening round.

Initial Screening Round ( 90 minutes)

This round consisted of 19 MCQs and 2 coding questions on Hackerrank. The MCQs were similar to the ones asked in previous year GATE CSE papers. The coding questions were as below:

  • Find the largest connected island
https://leetcode.com/problems/max-area-of-island/

I wrote the following code and passed all test cases:

  • Print anagram groups
https://leetcode.com/problems/group-anagrams/

NOTE : You can read hints for solving anagram related questions in this story:

I was able to complete both coding questions and attempted almost all MCQs. I got shortlisted for F2F interviews.

F2F Round 1 (60 minutes)

The interviewer was a senior engineering manager of Amazon. He started off with a brief introduction. He walked through my resume and asked some questions regarding my projects and previous work experience. After this he immediately jumped into algorithm questions:

  • Find (1/n) th node in a linked list.
https://www.geeksforgeeks.org/find-fractional-nk-th-node-linked-list/

If length of the linked list is 6 and n=3 then return the 2nd node, also I have to handle the case where 1/n times length is not a proper integer. I was given a few minutes to think and I got the idea of using two pointers with a little bit of math to figure out the pointer movements. He then improvised the question to make it more generic like:

  • Find (m/n) th node in a linked list. (Given : m≤n)

If length of the linked list is 27 and m=2 and n=3 then return 18th node, also I had to handle case when m/n is not a reduced fraction. I wrote a working code, I felt he had some other approach in his mind, but he was happy with what I did. This is what I finally ended up writing:

  • Given a character array we need to compress it in-place as follows:
    aaabcccdd → a3b1c3d2 (no resizing needed)
    abcd → a1b1c1d1 (resizing needed)

I started off with a brute force solution where I found character burst length and try to put the burst size next to the starting character as I iterate over the array. But this didn’t work as I started overwriting the characters I haven’t visited. This question had a lot of cases to handle and solving it in-place was the hardest part of the problem. The whole idea here is that any character burst will need 2 slots in the final array and the lone characters are the ones that will need additional slots. So I decided to first iterate on the array to identify bursts with length more than 1 and then put the burst size in place of a redundant character and emptied the slots of duplicates. I also kept track of the number of lone characters and empty slots in the array. He threw in more edge cases and I couldn’t fully solve this question as time was running out. I up-solved this later after my interview and I have shared the code here.

In the last few minutes, it was my turn to ask him question and I asked him why Amazon concentrates too much on algorithms and data-structures in their interviews. How much of it comes in day to day work? He gave a really good example and gave some insights on the work his team is doing. Overall, I felt the interview wasn’t my best but luckily I made it to the next round.

F2F Round 2 (60 minutes)

The interviewer said this round would be very important for me and I guessed it would be my Bar Raiser round. I also saw a sticker with Bar Raiser written on his laptop. He said I will be given two algorithm questions and asked me which data structure I am comfortable with, for which I said trees.

  • Print the top view of a binary tree
https://www.geeksforgeeks.org/print-nodes-top-view-binary-tree/

I proposed an approach using level order traversal with an augmented tree node to store the vertical level and a map to store the top view nodes at each vertical level in the tree. He asked to do it without a map. I was given 15 minutes to come up with the best solution and he left the room. I think he was simultaneously taking interview of another candidate. I thought for a moment and decided to keep track of the range (min and max) of vertical levels as I discovered nodes in the level order traversal. He then came back and said it would work and asked me to write it on a paper. This is what I ended up writing:

  • Find the max sum path in a binary tree
https://leetcode.com/problems/binary-tree-maximum-path-sum/

I have seen this question on leetcode but never tried to solve it as it was in the Hard section. He gave me 20 minutes to come up with an approach. Before he left the room I did ask about the time complexity and space complexity he was expecting. He wanted it in a single traversal using minimum space possible. I couldn’t figure out anything in the first 5~10 minutes. But then I got an idea that a modified postorder traversal might work. The idea is to keep track of the overall max path in each subtree and also best path starting at each subtree root. He came back and I explained my approach. He was happy with it, but he said my approach won’t work for trees which have negative numbers. I modified my approach to handle all cases and he asked me to write clean code on a paper. This is what I ended up writing:

Overall this round went really well and the interviewer was super helpful and I made it to next round.

F2F Round 3 (60 minutes)

The interviewer said she will be concentrating more on algorithms and data structures.

  • Find the minimum cost to connect ropes
https://www.geeksforgeeks.org/connect-n-ropes-minimum-cost/

I have solved this question before and I knew the approach. It’s a typical heap data structure problem and I wrote working code as follows:

  • Given x and y swap two nodes in the linked list (swap nodes and not data). Also the nodes contain distinct values.
https://www.geeksforgeeks.org/swap-nodes-in-a-linked-list-without-swapping-data/

At first it appeared to be one of the easiest questions. I got a bit confused with the problem description (words like ‘distinct’ ). I felt that the interviewer had deliberate intention to trap me with all the edge cases and the confusing problem description. I assumed x and y are distinct, and also that they are present in the linked list which I shouldn’t have. I tried to write the code and there were several corner cases that I had missed which she pointed out (including my assumptions) and this resulted in my elimination.

The HR told me that I didn’t clear this round. But, I was later informed that they are offering me a 6 months internship. I accepted the internship offer and later got a full time offer at the end of my internship.

My Two Cents

All the interviewers expects you to write the most optimized error proof code. This can only come from practice. I also felt that communicating my thoughts clearly was helpful and it kept the interviewers engaged. Finally, I realized you don’t need to solve each and every question fully to end up with an offer.

“No matter what you’re going through, there’s always a light at the end of the tunnel”

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Responses (3)

Write a response