Skip to content
Related Articles

Related Articles

Amazon Interview experience (Off-Campus 2019)

View Discussion
Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 15 Jul, 2019

Hi all, Amazon conducted a pool drive in January 2019 in Gurugram. We were shared a link for the test hosted on HackerEarth. The pattern of the test was 20 MCQ’s and 2 Programming Questions.

Online Test:

20 MCQ’s based on OS, Network, COA, DBMS, OOPS.

Q1: Given a NxM Grid. The grid consists of only 3 integers(0, 1, 2)

  • 0 denotes empty cell.
  • 1 denotes a cell containing plant.
  • 2 represents a cell where you are standing currently.

You can move to adjacent cells (Up, Down, Left, Right). Find the length of the shortest path to reach one of the boundaries without stepping on a plant.

Length of the path is the number of moves you make.

Q2: You are given some rules (<=26) an integer K.You can make several permutations of the rules while keeping the given rules fixed.

Write a program to find the Kth lexicographically smallest permutations of the rules.


bcd (Rule)
xyz (Rule)
1 (K)


Alphabets b, c, d have already been mapped to be represented x, y, z respectively. Now we need to find the lexicographically smallest (K=1) permutation of the alphabet. This is done if we assign each remaining alphabet to the earliest possible position in the permutation. Hence, the answer is axyzbcdefghijklmnopqrstuvwxyz.

I got the first question complete and the second question partial which was enough to qualify for the face to face interview.

Round 1:

Q1: ZigZag Tree Traversal

Q2: Binary Tree to DLL

I answered them both.
The interviewer first asked me to think of the approach and explain that approach to him.Once he was satisfied with the approach, He asked me to write production level code.

Round 2:

Q1: Given a list of IP addresses [,, … ]. Remove duplicate IP’s in the list.

Sol: I gave the first answer that store the IP addresses in a set while iterating and if IP is found in set, remove it.
However, Interviewer wasn’t satisfied with the space complexity so he told me to reduce the space complexity.
I came up with a tries based solution where instead of storing an IP in set, I store it in Trie.(Space complexity is reduced as Node in Trie doesn’t take up space unless allotted a value as well as instead of creating a new node for every IP, in Trie a node can be reused if even half of the IP is same).

Q2: Maximum path sum
(Without Space Complexity)

Solved the first question completely but took more time, so couldn’t solve the second question on time.

Verdict: Rejected

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!