 Open in App
Not now

# Amazon Interview | Set 84

• Difficulty Level : Hard
• Last Updated : 19 Jun, 2019

I attended a hiring event for Amazon in world trade center in bangalore.

First round was coding test (Written round) :
1. Given a string of parenthesis, write a function if it is balanced.
2. Convert BST to a Doubly linked list.
3. Find the number of occurrences of words in a paragraph.

First Round :
2. Asked some questions on resume.
After some friendly talk, jumped on technical but easy questions :
1. Implement BFS.
2. Difference between Dijkstra and BFS.
3. Given a linked list, find out if the list is circular, also find the point from where the cycle start.
4. Given an array, find the max sum over a sub array.
5. If you have two eggs, how many max steps you need to find the floor, from which the eggs break.
And some more easy questions.

It was already 5, so they decided to have further rounds later.

10 days later I had attended interviews :

First Round :
1. Asked about heaps, given an array, tell if it is min heap, if not, apply operation min-heapify.
2. Is a heap a complete binary tree?
a. What happens when two numbers map to same key?
b. how does chaining work?
c. What to do when you have a bad hashing function, and only we can modify the structure of hashmap not hashing function?
d. What do to when you your hashmap is filled completely (as in all the linked list are filled up to their capacity)
4. What is quicksort? Implement for a linked list and tell complexity.

Second Round :
1. What is quicksort?
a. What is complexity when all elements are sorted and how can you improve it? (Randomization)
b. Will randomization work when elements are same?
c. What algorithms sort equal elements in O(n) time ?
d. using the information, how can you improve quick-sort? Think about it, its good. Don’t want to spoil it for you by writing answer here.
e. implement this modification.

2. Given two river banks (visualization : two parallel lines), one bank has numbers written (1….n) in sorted order. On the other bank the numbers (1…n) are arranged randomly. A bridge can be formed from the ith point from bank 1 to ith point in bank 2. Find the max number of non-intersecting bridges you can form?

3. Given 1…n , and given some statements like i hates j, then find some arrangement of n numbers such that if i hates j then in the arrangement i comes before j. Say 1 hates 2, then 123456789 is acceptable but 213456789 is not.