On thursday evening I received a call from Amazon after 1 month of OA that I have interview tommorow, no email regarding OA cleared or nothing, I asked HR to shift the interview next week, but she was saying no slot available. As I was preparing for Google also So I gave the interview, two simple questions
- For Each of the node in a binary search tree replace that node value with the sum of all the elements greater than that node value in the tree.
-> told brute approach of inorder traversal, storing in array as inorder of bst will be sorted. doing suffix sum and then iterating over tree again and then replacing the value.
-> Optimal : I was in the right direction of going in the right subtree first and then root and then left, all i need was to maintain a variable that should store the current sum, but interview asked to move to the next question.
- top k elements in stream
-> started with brute of storing the elements in a vector and then storing each time a new elements comes and sorting and then giving top k elements
-> Optimal : priority queue I first told only single priority queue, but I don't know what happend to my mind and i moved to two priority queue one min heap and one max heap, min heap for the elements and max heap to see the largest element so far in the min heap, messed up
they asked the internal implementation of heap, I was unaware and I told Red black tree (used by set) got into depth of this only but still messed up and told everything about binary search tree.
What are my chances to move to second round, and is anyone rejected after first round ?


