The Find Bottom Left Tree Value interview question asks you to find the value of the leftmost node in the very last row of a binary tree. The "last row" is the row with the maximum depth. Even if there are nodes on the left in higher rows, you are specifically looking for the one at the deepest level.
Microsoft and Amazon frequently use this problem to evaluate a candidate's mastery of tree traversal techniques. It tests whether you can distinguish between different levels of a tree. It evaluation your proficiency with both the Breadth-First Search interview pattern and the Depth-First Search interview pattern. While both work, the BFS approach is often considered more intuitive for "row-by-row" properties.
There are two main approaches:
maxDepth, update the maxDepth and the resultValue.Consider this tree:
1
/
2 3
/ /
4 5 6
7
The "Right-to-Left BFS" is a clever trick that makes the code for this problem extremely short. Instead of tracking levels, just push the right child then the left child to the queue. The last node popped is always the bottom-left.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Find Largest Value in Each Tree Row | Medium | Solve | |
| Reverse Odd Levels of Binary Tree | Medium | Solve | |
| Count Good Nodes in Binary Tree | Medium | Solve | |
| Add One Row to Tree | Medium | Solve | |
| Sum of Nodes with Even-Valued Grandparent | Medium | Solve |