I recently (27-03-2025) had the opportunity to appear for the Amazon SDE interview, which consisted of a Two intense DSA rounds in one day. In these rounds, the interviewer tested me on a mix of problem-solving, logic-building, and optimization awareness. I was asked 4 DSA questions, 2/round, each evaluating different skillsets.
🔹 Question 1: Binary Tree – Sum Tree Validation
Topic: Binary Trees, Recursion
I was given a binary tree and asked to determine if it satisfies a specific sum property (i.e., whether each node’s value equals the sum of its children’s subtree values).
Concepts Tested:
- Post-order traversal
- Recursive return of tuple
(isValid, sum)
- Handling base cases for leaf nodes
🧠Tip: Be confident with writing custom recursive functions and returning multiple values from each call.
🔹 Question 2: Grid BFS – Virus Spread Simulation
Topic: Matrix, Multi-Source BFS
This problem simulated an infection spreading across a 2D grid. Each infected cell (P
) spreads to its adjacent non-infected ones (N
) per time unit. The task was to compute the minimum time needed to infect all reachable people.
Concepts Tested:
- BFS using a queue
- Level-wise traversal (multi-source)
- Grid bounds and visited updates
🧠Tip: Practice BFS on 2D grids, especially with multiple starting points.
🔹 Question 3: Range Coverage – Router Signal on Buildings
Topic: Arrays, Prefix Sum, Greedy
Given routers placed on buildings with certain ranges, I had to compute how many buildings are adequately served (i.e., covered by enough routers compared to the number of people in them).
Concepts Tested:
- Range marking via prefix sum
- Efficient array manipulation
- Early stopping conditions
🧠Tip: Learn how to apply difference arrays to mark and process range updates efficiently.
🔹 Question 4: Graph Reconstruction – Circular Sequence from Pairs
Topic: Graphs, Adjacency List, Traversal
I was given unordered pairs of adjacent symbols forming a circular sequence. The task was to reconstruct a possible valid sequence of those symbols.
Concepts Tested:
- Graph building from undirected edges
- Identifying a cycle
- Visited tracking during DFS or BFS
🧠Tip: Be ready to reconstruct orderings from unordered pair data, using adjacency lists.
✅ Final Advice
This round tested:
- Recursion depth (Tree problems)
- BFS reasoning (Simulation & infection spread)
- Optimized array processing (Greedy, prefix sum)
- Graph traversal and cycle detection
To prepare well:
- Master recursion with trees
- Practice BFS from multiple sources
- Learn range-based greedy techniques
- Get comfortable with graph fundamentals using adjacency lists
I still don't know if there are even implementing these algorithms Amazon. Waiting for the result :/
Top comments (0)