Amazon Interview experience (Off-Campus 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.

Eg.

Input:
bcd (Rule)
xyz (Rule)
1 (K)

Output:
axyzbcdefghijklmnopqrstuvwxyz

Explanation:
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: https://www.geeksforgeeks.org/zigzag-tree-traversal/



Q2: https://www.geeksforgeeks.org/convert-given-binary-tree-doubly-linked-list-set-3/

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 [192.12.23.45, 234.23.56.89, … ]. 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: https://www.geeksforgeeks.org/find-maximum-path-sum-in-a-binary-tree/
(Without Space Complexity)

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

Verdict: Rejected

Write your Interview Experience or mail it to contribute@geeksforgeeks.org

Join Free Interview Preparation Course



My Personal Notes arrow_drop_up

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


2


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.