Find Bottom Left Tree Value - Problem

Given the root of a binary tree, return the leftmost value in the last row of the tree.

You need to find the value of the leftmost node in the bottom-most level of the tree. If there are multiple nodes at the same level, return the leftmost one.

Note: The tree is guaranteed to be non-empty.

Input & Output

Example 1 — Standard Tree
$ Input: root = [2,1,3,4,null,5,6,null,null,7]
Output: 7
💡 Note: The bottom level has one node: 7. This is the leftmost (and only) value in the last row.
Example 2 — Multiple Bottom Nodes
$ Input: root = [1,2,3,4,null,5,6]
Output: 4
💡 Note: The bottom level has nodes [4,5,6]. The leftmost value is 4.
Example 3 — Single Node
$ Input: root = [1]
Output: 1
💡 Note: Only one node exists, so it's the leftmost value in the last (and only) row.

Constraints

  • The number of nodes in the tree is in the range [1, 104]
  • -231 ≤ Node.val ≤ 231 - 1

Visualization

Tap to expand
Find Bottom Left Tree ValueInput: [2,1,3,4,null,5,6,null,null,7] → Output: 72134567Level 0Level 1Level 2Level 3 (Bottom)Leftmost at bottom: 7Answer: 7
Understanding the Visualization
1
Input Tree
Binary tree with multiple levels
2
Identify Bottom Level
Find the deepest level in the tree
3
Find Leftmost
Return leftmost value from bottom level
Key Takeaway
🎯 Key Insight: Use BFS to process the tree level by level - the first node visited at each level is automatically the leftmost
Asked in
Google 15 Amazon 12 Microsoft 10 Apple 8
180.0K Views
Medium Frequency
~15 min Avg. Time
2.2K Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen