# Amazon Interview | Set 111 (On-Campus)

Amazon visited our campus, these are the questions that I faced.

**Online Round (90 minutes)**

20 MCQs(Data structure, C, C++, OS, Probability ).

2 programs :

1. Given an array of integers. Segregate all the non-zero numbers at the beginning. Print the number of non-zero integers and the minimum number of swaps required for these operations.

Eg. : I/p : 1, 0, 0, -6, 2, 0

o/p : Number of non-zero integers : 3

Minimum number of swaps : 2

E.g. : I/p : txt[] = “BACDGABCDA” pat[] = “ABCD”

o/p :0,5,6

**1 ^{st} PI**

- About 10 minute discussion on my project on Cloud Platforms and Big Data Analysis in Yahoo SDC. I asked him some doubts and he answered them clearly.
- Given a string of digits, output all the dictionary words they can represent. (Basically smart dial algorithm of an android phone). Each digit represents the corresponding characters on a cellphone as follows.

e.g. : I/p : 3323 O/p : DEAD , DEAFFirst, he asked me how I would store the dictionary. When he was satisfied by my approach, he asked me to write a recursive function that would do the job if a dictionary is given as an input. - Then he gave me a class design. He went on changing his requirements and I was asked to add support for them in my implementation. At first, his requirement was to draw a rectangle and a circle. Then he went on adding requirements and finally it was to draw different specializations (like curved-edges, skewed-edges, dashed-lines) of rectangles, triangles and circle. He gave a constraint that support for a new specialization can be added easily in my design.

**2 ^{nd} PI**

- Given, the starting and ending time of different meetings, what is the minimum number of conference rooms that will be enough to accommodate all of them.He asked me to code it.E.g, :
I/p : Meeting I – 8:30 – 12:50

Meeting II – 10:15 – 11:30

Meeting III – 11:45 – 1:30

O/p : 2

- Implementation of a doubly-linked list using a single pointer. I didn’t know the answer at that time. He gave me a few hints and I was able to solve it. Then he asked me to code it.

**3 ^{rd} PI**

- Given an array of integers. This array denotes ‘our’ own ascending order of the elements. So if the array is {2,3,1,4}, by mathematics we can say that 2<3<1<4. Given another array, sort this new array in ‘our’ ascending order.

Let’s say the new array is {1,2,4,3,5,4,9,2}, output will be {2,2,3,1,4,4,5,9}. Note that since 5 and 9 do not occur, they are sorted by actual ascending order at the end. - Return the left-view and right-view of an n-ary tree in a single traversal.

**4 ^{th} PI**

- 10 minute discussion about my internship in Cloud Platforms team in Yahoo SDC. He asked me a few HR questions like what do you think was your biggest screw-up in college life, etc.
- Find power(a, n) iteratively without extra space in O(log n) time. He gave me a lot of hints. But unfortunately I couldn’t solve it.
- Pre-order traversal of a binary tree without using recursion.

Fortunately, I was selected as an FTE in Amazon.

**Suggestions**

I would like to give a few suggestions to all the upcoming candidates :-

- Firstly, mugging up of codes will never take you far. If you find a problem that is solved in geeksforgeeks, rather than blindly mugging up the code, read the description properly. Try to understand what is being done and why is it being done. Try to understand each and every line of code. It is naïve to expect common known questions in interviews. But, if you can understand the approach of the codes solved in geeksforgeeks, you can use it to solve a plethora of problems.
- In an interview, always think out loud. Explain what you are doing and why you are doing it. If you solve a problem within a few minutes without explaining your steps, the interviewer will assume (perhaps not incorrectly), that you have mugged up the code. This creates a very bad impression.
- Follow proper etiquettes. Shake the interviewer’s hands while entering and while leaving the room. Also, try to ask proper questions to the interviewer when he gives you the chance to do so. These are the small things that set you apart from the other interviewees.
- Lastly, never be too tensed. Always remember, rejection is a part of life. Luck matters a lot in job interviews. So don’t be disheartened if you are rejected. You can always apply later.

A very best of luck to all of you for your upcoming interviews.

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:

- ServiceNow Interview Experience Oncampus
- Amazon Interview Experience | Set 180 (Telephonic Interview )
- Amazon Interview Experience (Telephonic Interview)
- Amazon Interview Experience | Set 249 (Telephonic Interview)
- Amazon Interview -SDE 1 Interview Experience
- Amazon Interview | Set 19
- Amazon Interview | Set 33
- Amazon Interview | Set 87 (For SDE)
- Amazon Interview | Set 30
- Amazon Interview | Set 84
- Amazon Interview | Set 22
- Amazon Interview | Set 53 (For SDE-1)
- Amazon Interview | Set 29
- Amazon Interview | Set 86
- Amazon Interview | Set 28