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

• Difficulty Level : Hard
• Last Updated : 23 Aug, 2019

Amazon visited our campus to offer internship for 6 months. There were 3 rounds – an online coding round and 2 face to face interviews.

Online coding Round(Duration:1 hr 30 mins)

This round was conducted on hackerrank.com. There were 20 mcq’s related to computer science and aptitude.Many of these questions are there in the MCQ section of GeeksForGeeks. And there were 2 coding questions:

```Input : m=5,n=5.
Mat[] = 1 1 0 0 0
0 1 0 0 1
1 0 0 1 1
0 0 0 0 0
1 0 1 0 1
Output : 5
First: (0,0),(0,1),(1,1),(2,0)
Second: (1,4),(2,3),(2,4)
Third: (4,0)
Fourth: (4,2)
Fifth: (4,4)```

Face to Face Interview-1(Duration:1 hr)

Interviewer started asking questions straight away without any introduction. He asked me the worst case complexities of Quick sort and Merge sort. Then asked me 2 questions related to trees:

1. https://practice.geeksforgeeks.org/problems/tree-from-postorder-and-inorder/1? I said no. Then he asked if i can make a binary search tree from the array to which i said yes. Then after discussing the approach, he asked to write the code.
2. Then he asked me to write the code for level-order traversal of a tree. Also asked me to calculate the complexity of the code
3. .

Face to Face Interview-2(Duration:about 1hr 30mins)

Interviewer started with the general introduction. Then he started asking questions.

1. Given n appointments with the start time, end time and a boolean variable hasConfilct, we have to set the boolean variable hasConflict of those appointments that conflict with the other appointments.
```Example:  Appointment1: (2:00-3:00)
Appointment2: (2:30-3:30)
Appointment3: (4:00-6:00)```

I have to set the hasConflict of Appointment 1 and 2 as true.
Initially, I did it in O(n^2). But then he asked me to optimize the solution. After some discussion, I was able to solve it in O(nlogn).

2. Given that at Amazon.in the details page of an item shows only one field that is dynamically picked up from the database, we have to improve the performance according to the line:
“80% of the users visit details page of 20% of products.”
I said we could store these 20% on the web server so that we don’t have to fetch the item details from database everytime. He asked me where and how will i store it. I answered Main memory and will use BST to store it. Then after a lot of discussion(about 30 mins) on how will the get and put operations be used, he was satisfied with the solution.
3. Given a linked list placed in memory, what problems can arise if simultaneous operations are performed on the list. From here he started asking about threads because the answer was related to it.
4. When a single threaded application is converted to multi-threaded applications, what kind of changes operating system has to make?
5. What steps are taken when the os shifts from one-thread execution to another?

Finally, I was hired. Thanks to GeeksForGeeks for helping me throughout my interview preparation.

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.

My Personal Notes arrow_drop_up
Recommended Articles
Page :