# Amazon Interview Experience (On-Campus)

• Difficulty Level : Hard
• Last Updated : 07 Jan, 2020

Amazon visited our campus for FTE as well as internships for SDE-I.

Initial coding test was conducting on hackerearth with:
1. About 18 MCQ’s based on CPP and time-complexity.
2. 2 coding questions:

• Finding shortest subarray which contains all distinct characters of that string.
• To find maximum occurring element in an array between L and R(indexes), which has been concatenated k times.

Completing a single coding question with good score in MCQ’s was enough to get shortlisted for the next round.

About 16 students were selected after the coding round.

Round 1: The interviewer was young and friendly. He asked me to introduce myself along with my internship project. Then he started with the coding questions:
1. Finding sum of all nodes with odd values in the path connecting two nodes. My solution approach was to store the paths for both nodes in vectors, and then take the sum of all nodes after the LCA.
2. Implementing sqrt (using Binary Search).
The interviewer was satisfied with my answers and asked me to code them and then dry run them.

Round 2:
The interviewer started straight with coding questions. He gave me some standard questions like top view of binary tree, maximum area in histogram and minimum cost to connect ropes. The last question was to:

Find all pairs such that A[i] > A[j] & i < j for an array. For example: arr[] = [5, 7, 8, 2, 1], the answer should be: (5, 2)(5, 1)(7, 2)(7, 1)(8, 2)(8, 1)(2, 1) total : 7

I realized that it was basically: https://www.geeksforgeeks.org/counting-inversions/ .

Round 3:
The interviewer was a very experienced person and was the manager of some major department. This round seemed like a HR round as he was asking me questions like – the moment I felt most important in previous 1 year, difficulties faced during my internships and all.

Finally he gave me a Design question to implement Google Maps. I came up with different approaches and finally gave him the solution with greedy approach. He then told me to code Djikstra’s algorithm which I did. He also wanted to come up with an algorithm to get second shortest path.

Round 4:
The interview started with introduction and the he gave me some coding question. First question was to find inorder successor for a given Node, given a pointer to that node alone.
I asked him if I can make some assumptions, so I came up with an approach using parent pointer.
The next question was based on Graph. For a given directed graph, find the shortest path from source to destination, if we can add a edge in between any two un-conneced nodes.
I gave him a solution approach by forming a connected matrix, finding all-pair shortest path(Floyd Warshall) and then checking for all intermediate nodes between src and dest nodes.

He was satisfied by the solution approach, but asked me if I could come up with a better approach. He finally gave a solution approach based on BFS, even though there were many loop-holes in it.

All the students were asked to leave and wait for the results.
Finally they shortlisted 3 students and I was one of them 🙂 .

Tip:
Coming up with a solution approach was not enough. They wanted to a fully-functional coded solution, with all corner cases covered as well.

I would like to thank GeeksForGeeks for the extensive questions as well as solutions available on it. I am not a competitive coder, but different websites like Leetcode, Interviewbit and GfG, definitely helped me to solve and learn a wide range of problems.

My Personal Notes arrow_drop_up