# Amazon Interview | Set 122 (On-Campus for Internship)

My interview comprised of 3 rounds. 1 Online and 2 face to face rounds.

**Online Round**

In this round there were 20 MCQ’s to solve and 2 coding question. Of the 20MCQ’s a couple of questions were on Quantitative aptitude, relationships, OS, DBMS, Data structures etc. there was negative marking for every wrong answer so I attempted only 15 for which I was sure.

Q1- find the first non repeating character in a string.

Maxweight = value of root node + value in its left subtree and right subtree.

Ex 2 / \ -1 3 Output = 4

After this round 33 students were selected for face 2 face round. 😀

**Round 1 F2F (40-50 mins)**

Q1 – given a binary tree where the left subtree is mirror image of right subtree. So you have to check whether the tree is symmetric or not (structure wise). O(n)

Ex - 1 / \ 2 3 \ / 4 5 Output - Yes

Q2 – given a sorted 2D matrix and you are given a value you have to search that value in the matrix. I gave him two solutions. O(row + col)

Q3 – given two arrays in sorted form. The first array has some empty space equal to the size of second array at its end. You have to merge both array in the __ smartest possible__ way in the first array. With constraint that auxiliary space O(1).

Ex – arr1[9] = {2,4,5,7,8,_,_,_,_};

arr2[4] = {3,6,8,9};

after merging arr1 should be = {2,3,4,5,6,7,8,8,9};

For every question I was asked to write a working code with all corner cases handled. I impressed the interviewer very much in this round :). Then I ask him some questions like – how an intern contribute to the amazon’s claim to be the most customer centric company and a few more.

Round 2 F2F (70–80 mins)

This interview was with a senior guy.

Q1 – Given a very large n-ary tree. Where the root node has some information which it wants to pass to all of its children down to the leaves with the constraint that it can only pass the information to one of its children at a time (take it as one iteration). Now in the next iteration the child node can transfer that information to only one of its children and at the same time instance the child’s parent i.e. root can pass the info to one of its remaining children. Continuing in this way we have to find the minimum no of iterations required to pass the information to all nodes in the tree.

Minimum no of iterations for tree below is 6. Consider passing root information first to any child except A-B answer will come more then 7. So 6 is the minimum answer.

I gave many approaches for this question but he was not satisfied with any approach. I said I will try to do it in a binary tree then I will generalize it for n-ary tree. He said your binary tree approach is correct but the way you are generalizing it to n-ary is wrong. The interviewer gave me many hints and said you have almost solved the question but missing a single point which I was not able to find till the end. Finally he moved to other question.

Q2- given a binary tree you have to check whether it is BST or not.

This question was very easy. I solved it within minutes (one inorder traversal approach O(n)) but to my surprise the interviewer was saying it is wrong. I explained to him but again he said it is wrong. His motive was to pressurize me but I stick with my solution and finally he moved to other question. My answer was correct.

Q3 – given a BST find the Nth maximum and Nth minimum element.

I solved it in O(n). He was fine with it but he said do it in logarithmic time. I did it too with some preprocessing and coded both the approaches.

Overall it was a very nice experience interviewing with them.

**Some tips:**

- Be confident. Don’t let the pressure prevail on you.
- Amazon is mainly looking for those who can write code, only telling approach is not fine. So start practicing as much as you can. There is no barrier of programming language.
- Please do ask questions to interviewers when they ask and try to ask something which shows that you are very much interested in working with them
- www.geeksforgeeks.org – my guidebook. Utilize the immense resource available on this portal for your benefit but don’t mug up the code. Try to first solve it by yourself.

Good Luck !!!

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

## Recommended Posts:

- UHG Interview Experience | OnCampus- 2019
- ServiceNow Interview Experience Oncampus
- MathWorks Interview Experience (EDG, Oncampus)
- InfoEdge Interview Experience | OnCampus-2019
- Amazon Interview | Set 54 (For Internship)
- Amazon Interview | Set 60 (For Internship)
- Amazon Interview | Set 61 (For Internship)
- Amazon Interview | Set 52 (For Internship)
- Amazon Interview | Set 45 (For Internship)
- Amazon Interview | Set 44 (For Internship)
- Amazon Interview | Set 70 (On-Campus For Internship)
- Amazon Interview Experience | Set 265 (For Internship)
- Amazon Internship Interview Experience
- Amazon Interview Experience | Set 407 (Internship)
- Amazon Interview Experience | Set 421 (For Internship)