Amazon SDE 1 | Round 1

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-05-17Added By Anonymous
Source: Link

Company: Amazon
Role: SDE 1
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

On Thursday evening I received a call from Amazon after 1 month of OA that I had an interview tomorrow. There was no email regarding the OA being cleared or anything. I asked HR to shift the interview to next week, but she said no slot was available. As I was preparing for Google also, I gave the interview. Two simple questions were asked:

1. For each of the nodes in a binary search tree, replace that node's value with the sum of all the elements greater than that node's value in the tree.

-> I told the brute approach of inorder traversal, storing in an array (as inorder of BST will be sorted), doing a suffix sum, and then iterating over the tree again to replace the value.

-> Optimal: I was in the right direction of going into the right subtree first and then root and then left. All I needed was to maintain a variable that should store the current sum, but the interviewer asked to move to the next question.

2. Top k elements in a stream

-> Started with the brute force of storing the elements in a vector and then sorting each time a new element comes, and then giving the top k elements.

-> Optimal: Priority queue. I first told only a single priority queue, but I don't know what happened to my mind and I moved to two priority queues: 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. I messed up. They asked for the internal implementation of a heap. I was unaware and I told Red-black tree (used by set), got into the depth of this only but still messed up and told everything about a binary search tree.

What are my chances to move to the second round, and is anyone rejected after the first round?

Comments