Recently I got interviewed at Amazon Hyderabad. I just wanted to share my experience. Hope someone gets little help from this.
I did it with using Queue made of doubly linked list. Time complexity O(n), space O(n). I was asked to write code as well on collabedit site.
Did it O(n) time complextity and O(1) space. I was asked to code it as well.
Explained different methods for it and he asked me to code for one.
I did it as follow.
void findPairs(node *start, int k)
if(start == NULL)
if(k – start->data > start->data)
if(search(start->right, k – start->data)) // this search is normal BST search.
printf(“(%d, %d), “, start->data, k – start->data);
b. There were few other simple questions. I don’t remember know.
1. Onsite: with Hiring Manager.
a. About Project, cross questioning, etc.
b. Two files containing large number, one in each. You have only fopen(), int read(fp), fclose(), fwrite(). Add these two numbers and write in third file with the help of given functions only.
Explained him the logic and he was okay with it.
c. Write sql query for getting direct and indirect reportees of a given employee. Lets say Employee table(empId, ManagerId).
wrote it and he verified it and it was okay. Recursive query, CTE.
d. Oops concepts, asked to explain Static keyword with all possible example.
Explained, variable, methods, classes one by one with Static keyword.
2. Onsite: with Developer.
a. Print encoding for an Array.
Rules: consider BST made from given array. Let say number x is present in the BST and to reach x, If you go right print 1, if left then 0.
Now you are given an index i in the array A (so x = A[i]) and print the encoding without constructing BST to reach x
and without space with least time complexity.
I was not able to do it on the spot but after this interview, I got some free time and solved it and handed over papers to the interviewers. I liked this problem. It was little interesting.
c. Then moved to finding all possible pair set in an array. Mind the term SET. Take care of duplicates as well.
Reduce time complexity as much as you can.
3. Onsite: with Developer.
I coded it with just 4-5 lines in just couple of secs. It took little time to make him understand the solution.
I was given an input of 6 numbers in an array and asked to run my solution till the end. It was recursive and he asked me to keep on writing, writing, writing, till he got that okay, it will work fine.
b. I was asked couple of questions which I already knew and I told him and we moved on to next questions. I don’t remember what he asked.
4. Onsite: with One Manager and Senior SE.
a. Discussion on my current Project. Quite a good discussion. It took quite a good time.
They asked me what more enhancements I can think of for features, I made in my project.
I explained few different things that I could think on the spot and they liked it.
I already knew the best approach for this. Then he asked me to think something else. I mentioned Hash. He was okay with it and we moved on.
I told him I already know this and I asked if he wants me to explain the algo. He said so and I explained. Then we moved on.
e.g. 1->2->3->4->5->6->7-_ given
Explained them all possible methods for this what I could think of(with space, without space). Finally, they were looking for BitMap solution. I explained that as well before one mentioned it.
f. Design a Chess game.
Gave different classes and their relations, some procedures, then cross questioning and I was able to give all answers which he mentioned quite reasonable.
They were okay with the design.
In the whole interview process I was asked like 8-10 questions which I already knew and I mentioned the interviewers same. I was told why you read so much.
Overall, it was quite a good experience for me. I liked the way interviewers were interacting. They were very supportive and friendly as well.
Unfortunately, I was not selected. 🙁 I have no idea what they were looking for.
Thanks to Vinay for sharing Amazon Interview experience. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.