Skip to content
Related Articles

Related Articles

Amazon Interview Experience | Off Campus for SDE-1
  • Difficulty Level : Hard
  • Last Updated : 16 Jul, 2019

I took a referral from senior working in Amazon and got online test link. There were two coding questions and few MCQs based on OS and Networking and other CS fundamentals. Coding questions of 20 marks while each MCQ carry +3 for correct and -1 for the wrong answer. The coding questions were as following

1. There is a string let’s say ABCDJHGDCBA. You can cut string once and append left part to right string. There is one rule while appending the string, i.e, at the joint of two strings characters keep canceling out each other till they match. So we have to print the minimum length of the string we can get after cutting and attaching the left and right half.
For example, we cut given string in AB and CDJHGDCBA then after addition, the result will be CDJHGDC. So minimum length we can get by ABCD & JHGDCBA. Basically, we have to find how much length is matching from left to right. And then subtract twice of matched length from the length of string.
2. Given some chocolate type id and their quantity. Also, it is given the priority order of chocolates in which you will eat chocolates. When you finish one type of chocolate then only you will eat other types. Also, you can eat only one type of chocolate on a given day. You have to eat at least one chocolate per day and at max, you can eat any amount. Given Q queries each consisting chocolate id and day number. You have to print YES if you can eat that chocolate id on given day else print NO.

I solved both coding questions and a few multiple choice question and my laptop shut down in between, so the test was terminated at that point. Still, I got an interview call.

Round 1:

First Question
Find the first circular tour that visits all petrol pumps

Second Question
Maximum sum such that no two elements are adjacent

Wrote fully functional code for both.

Round 2:

He asked which element will come at Kth place after sorting the array.
At first, I told him to use min heap of K elements then he restricted me to use extra space. Then I told him the quicksort method. Then he told to write the code.
K’th Smallest/Largest Element in Unsorted Array

Second question

There is BST and you will be given a number from it and a new number such that if you will replace the old number from new number BST properties will not change. So you have to write the code to clone new BST such that old number is replaced with new one such that we allocate minimum memory. There was lots of ambiguity the way he asked, So it took nearly 15 minutes just to clear the question.
Basically we have to write following code:

node* cloneNewBST(root, oldVal, newVal){
node* temp=createNode(newVal);
temp->right=root->right, temp->left=root->left;
return temp;
else if(root->data<oldVal){
node* temp=createNode(root->data);
temp->right=cloneNewBST(root->right, oldVal, newVal);
return temp;
node* temp=createNode(root->data);
temp->left=cloneNewBST(root->left, oldVal, newVal);
return temp;

Round 3:

First question was to sort a linked list using merge sort.
Second question
Trapping Rain Water

Wrote code for both.

Round 4:

There were two interviewers.
This round was a quite difficult one. Asked questions related to deadlock, LRU Cache algo indirectly (not mentioning LRU Cache but using another story which does similar to LRU cache).


  • Boggle (Find all possible words in a board of characters) In this question they wanted as much optimization we can.
  • There is a city in which you have to assign aadhar numbers starting from 1.If one person dies then you can assign his aadhar number to another new person. You will assign the first possible aadhar number for any new entry. They discussed data structure and how will we do it efficiently.

Verdict: Selected

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon and Microsoft Test Serieses.

My Personal Notes arrow_drop_up
Recommended Articles
Page :