# Amazon Interview | Set 34

First of all, a very very big thanks to whole team of geeks for geeks. It is because of them only that I was able to crack the interview process of amazon and get a job in my dream company.

**No of Rounds:** 1 MCQ round + 2 online test round + 4 PI

**Type of Interviews:** Campus Interview for freshers

**MCQ round(Time) : 45 minutes** 20 Objective Questions:

5 question on maths which included 3 on probability

Some c output questions easily available on geeks quiz

Questions on heap, hashing, time complexity of recursive functions

One sql query, one question on fcfs and round robin scheduling, page fault in demand paging, dining-philosopher problem,one on propositional logic, one based on Huffman code.

**Online test 1 (Time): 45 Minutes**

2 Questions:

**1.** Given three linked lists,where each linked list represents a number, add the three lists and return the resultant list.

5->1->2->NULL

9->1->NULL

7->2->2->NULL

Output :: 1->3->2->5->NULL**2.** Given an array and two numbers x and y, find minimum distance between two numbers x and y. assume that x and y always exist in array and it may be that x and y are same also…

**Online test 2 (Time): 45 Minutes****1.** Convert a given binary tree to sum tree.

**Interview Round 1(75 Minutes):**

Technical Interview

Asked to give a brief idea about my project.

**Question 1:** Given a linked list,reverse every k nodes of the linked list.

**Question 2:** given a matrix of size m * n, place k students in such a way so that cheating in an exam could be minimized…. Was asked to just explain the approach, no code required.

**Question 3:** suppose a online chat between customer and serviceman, serviceman wants to reply to customer as soon as possible…suppose text which is to be sent as reply takes 10 sec for being typed. How can he make typing faster ?

My answer was using autoprediction feature, by which he will need to type less number of characters, so typing will become faster..

Then question was extended to how to store the words for being used in prediction…

I answered a trie data structure which allows prefix matching..

Then question was further extended to write a code to traverse all the words stored in dictionary in lexicographic order..

**Interview Round 2(50-60 Minutes):**

Technical Interview

First of all was asked to tell something about myself.

Then a detailed discussion about the project, conversation continued nearly for 20 minutes, he wanted me to explain him everything from the scratch.. I used genetic algorithm in my project..so he wanted to explain him the concept of genetic algorithm..

Then a coding question:: stable stock problem.

You are given prices of stock of a company at consecutive days in an array..write a code to find the maximum profit one can make by keeping a stock value for as long as possible..that value of a stock is called a stable stock value.

Example::

6 5 9 8 3

So maximum profit is 15, because stock of value 5 would be hold for 3 days. So max profit is 15.

The problem basically was a variation of finding index of next smaller element.

I solved it using the concept of largest rectangular area in a histogram where need to keep track of previous smaller will not be required.

**Interview Round 3(60-75 Minutes): (Bar Raiser Round)**

Technical Interview

Interviewer was very cool.. he first asked about me, did some casual talk to do away with my nervousness.

Infact, he told me that it looks like that you all have studied geeks for geeks very thoroughly so I am going to ask you a question that is not present in geeks for geeks. He challenged me it will be a question you have not heard of before. At the end of round, he showed me it was a question from top coder, but I had never heard of anything called top coder before.

**Question 1:** Given a string, find the longest sinusoidal sequence in it. If there are multiple such sequences of same maximum length, return the one which comes first in lexicographic order in a dictionary..

Sinusoidal means increasing then decreasing then increasing and so on.

Example ::

a r u n ::

a u n , a r n , r u n are three such sequences of length 3…. But, a r n is output since it comes first in lexicographic order.

Interviewer gave me hints that if I had to found the sequence in which all elements were increasing, then I answered LIS will give me the solution , this was the hint. So, basically, it was a variation of LIS. I answered it in O(n2) and 2n space….

Then was asked to do it in (n) space and o(n).

**Question 2:** Suppose a student needs to implement a bst structure to solve a problem, but instead he used a linked list…. Then give an example of input sequence, in which his implementation works… new value will always be added at beginning of a linked list.. so. Basically at each step after insertion , root of bst and head of link list should point to same node. I was asked to provide the sequence.

**Interview Round 4( 35 Minutes)**

This round started of with some nontechnical questions.. what will I do in different situations?

They seemed to have found out every detail of terms involved in my project..so, there was a detailed discussion on project… my project involved concepts of statistics, so he asked me questions regarding stats…. This discussion went nearly for half an hour…. In the end, he told me lets see whether your project could bring you to amazon….

After the 4th round, I nearly have to wait for 4 hours before the result were announced. Finally, the interviewer said they were highly impressed by me and I was hired.

In total 7 students were selected among us.

Once again a big thanks to whole geeksforgeeks team.

This article is compiled by Arun Jain. Many Many congratulations to Arun. 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.

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**. **Google** and **Microsoft** Test Serieses.