# Amazon Interview Experience | Set 267 (8 Months Experienced)

Recently, I got a chance to be interviewed by Amazon at Bangalore campus, through referral.

I had 8 months of experience in a product based company and 5 months of Internship.

**1st Round Telephonic :**

There were two guys, started with a formal introduction.

Question 1 : Given an array and a number say “Num1”. Find two numbers whose sum is equal to given number “Num1”.

I told him first Brute Force solution then he asked the time complexity which i told him O(n^2).

Then he asked me to optimize the solution and I gave a O(nlogn) solution using sorting.

And at last I told him O(n) solution using Hashing.

Question 2 : Given an array of stock prices . Determine the maximum profit one can get by buying and selling the stock(Similar to stack span problem).

I told him brute force solution of O(n^2) then he asked me if you could give an optimized solution.

I told him O(n) solution using stack but code got stuck on some of the test cases and he asked me to modify the code but i couldn’t as they were running out of time.

They provided me a link to Colabedit(kind of google shared document) where i had to code.Production ready code was required.

After 2 days I got call from Amazon saying that feedback was positive and they asked me to come for face to face interview at Amazon’s office.

**F2F Round 1 :**

Started with a brief introduction.

Q1: Given a M*N matrix. you have to start from Index(0,0) and reach to Index(M-1,N-1) with maximum sum , given the constraint that you can only move right or down i.e if you are at index (i,j), you can only move to index(i,j+1) or to index(i+1,j)

I gave recursive solution for this and there were a lot of discussion on various test cases.

He asked me to optimize the code. I gave him Dynamic programming approach . He asked that have you done it before and i said no then he asked me to code it. I had no idea of the code as i haven’t done it before. i struggled to write the correct code 2-3 times and at last i wrote the correct code.

Then he said to me i am done with the interview, Do you have any question for me and i asked two question.

Production ready code was required.

**F2F Round2 :**

Again Started with a brief introduction and some project discussion.

Q1: A question similar to LCA(Least Common Ancestor) of Tree and I gave the answer immediately as I have understood the question and didn’t ask any further clarification.

Q2: Given some resources in the form of the linked list you have to cancel out all the resources whose sum up to 0(Zero) and return the remaining list.

I gave the solution immediately but couldn’t handle some of the corner test cases then he asked me to modify the code accordingly.

Then he asked me to write all the test cases for it and i did.

For eg; given the resources like this :

case 1 : 6 -6 8 4 -12 9 8 -8 It should return 9 as all others get canceled.

In the above example lists which gets canceled :

6 -6

8 4 -12

8 -8

o/p : 9

case 2 : 4 6 8 -9 10 -9

o/p : 4 6

case 3 : 4 6 -10 8 9 10 -19 10 -18 20 25

O/P : 20 25

**F2F Round3 :**

Started with a formal introduction and BTW he was the same guy who took my telephonic interview.

Q1) He asked me subset sum problem i.e; Given an array find the maximum sum contiguous subarray.

I gave O(n) a solution for finding the maximum sum immediately after he asked the question as I knew the solution.

Then he asked me to trace the code for some test cases and it passed. Then he asked me to find the starting and end index of the subarray and I modified the code and initially got wrong but after some modification, I got the code right.

Q2) Sum of numbers represented by two linked list.

And I gave the answer immediately after he finished the question. But I gave the soln for adding two linked list numbers starting from the beginning but he told me to add the numbers as we do in normal addition.

And I gave that solution by reversing the linked list and then adding the numbers and finally reversed the resultant list.

After 2-3 days I got a call from Amazon that I have cleared the rounds and they asked me to come for Hiring Manager Round.

One of the interviewers gave me feedback that he mugged the answer as I gave the answer immediately after the interviewer asked the question as I came to know later which was a major setback for me.

So one of the advice would be to all of you that Even though you know the answer pretends that you don’t know. Ask some clarification question, As they also observe your problem-solving skills with coding.

**Hiring Manager Round F2F :**

Started with some basic questions and then asked why do you want to leave your current company and then he asked code Of the Fibonacci series.

I explained the Fibonacci series and then he asked me to code it.

I wrote the code and traced some inputs.

Then he had a meeting as I reached late there so he asked me to improve the code as he said there is some bug in the code and I did.

After that, he asked me to write recursive code for it.

Then he asked the time complexity of the code and I said Exponential.

Then he asked me to prove it.

I said sir I could do it using Master Theorem or using Mathematical Induction. But right now I remember none of them.

Then he told me that you can do it without Master Theorem or MI. Then in my mind, it struck me as the Recursion Tree Method but at that time I didn’t have any idea of the recursion tree method as well. So I couldn’t tell him.

This round wasn’t positive as I knew right after my interview. I got eliminated after this round.

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.

## Please

Loginto comment...