Amazon SDE 2 First Round & Second Round Interview Experience

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-03-27Added By Anonymous
Source: Link

Company: Amazon
Role: SDE 2
Interview Stage: Onsite
Location: unknown
Year: unknown

Original Post Content:

First Question:
In the first round, I was asked two DSA questions, both were based on graph.

First Question: You are given number of nodes in a network. To check if two nodes are connected or not, you can use a method isConnected(a, b).

Given n, you need to find out a node which has no outgoing edges and it has a direct edge from all other nodes.

I could only give a brute force solution for this, worst case time complexity of O(n^2)

Could not come up with an optimal approach.

Second Question:
You are given package dependencies in the form of a list (of edges). Need to find the total time taken to build all the packages.
This was basically topological sort question where you have to return the time taken after traversing through whole of the graph. (you have to parallel process nodes at the same level)

I first told him the BFS solve. He asked me if there was any other way to solve the problem.
I told him that we can use DFS as well, where we keep on returning the max value of the DFS branch like how we do in trees. He seemed satisfied with both approaches. Gave me a choice to code any of them. I went ahead with BFS only. And showed him a dry run for the same.

Leadership Principle:
Dive deep question -> When you were actually trying to understand your team's complex problem and you had to dig into the details to figure out. What was your approach?

Tell me about a time when you realized you needed to have a deeper level of subject matter expertise to do your job well?

This question went really well since I was well prepared and he had some follow up questions regarding metrics and all and I was able to give a good explanation.

Overall, I think it was good. Although I could not give an optimal approach for the first question, I think I did fairly well with the second DSA problem and the LP question.

Update About Second Round
I was asked three questions in this round.
First Question:
Q1: 1 - Island, 0 - water
For each of the points (1/0), find the distance to the nearest island.

input:
1 0 0 0 0 1
0 0 0 0 0 0
0 0 0 0 0 0

I was able to solve this easily with BFS.

Second Question:
In the second question, the interviewer wanted to ask something that I did not see before. So he asked a question on lock, unlock in a n-ary tree.

Given an N-ary tree. There are three methods you need to implement:
lock(Node* node)
unlock(Node* node)
isLocked(Node* node)

He gave me a Node struct with just this:
Node {
int val;
Node* children[]
}

The challenge was to figure out all the other fields that would be needed in order to bring down the complexity of lock and unlock methods.

3
/\
8 7
/\
5 1
/ \ /\
10

case 1 : none of my parents or children are locked -> node can be lock
case 2: one of my ascendants is locked -> this node cannot be locked
case 3: one of my descendants is locked -> this node cannot be locked

Question 3: Given an array, you need to give range sum queries.
When I said that I would use a prefix sum, he tweaked the question to say that the array will also be updated.
Which meant that to bring down update complexity, we would have to use something like a Segment Tree.
I have never studied Segment Tree, so I just could not do it.

LP: What is one time when you had to work out of your comfort zone to achieve something.

Next round is LLD, if anyone has any tips or know about popular questions, please let me know in the comments. It would be helpful.

Comments