Find Bottom Left Tree Value
Find the leftmost value in the last (deepest) row of a binary tree.
Open on LeetCode ↗Intuition
Walking left as far as possible sounds like it should find the bottom-left value, but it can land on the wrong node entirely: the deepest level might only be reachable by turning RIGHT somewhere higher up, and a pure left-walk never gets there. The fix is to level-order the whole tree and, on each level, remember only the FIRST node popped -- since BFS processes a level strictly left to right, that first node is that level's leftmost value. The last level recorded, once the queue empties, holds the answer; equivalently you could BFS right-to-left and just keep the final node touched.
Approach
BFS level by level
Process the queue one full level at a time, tracking the size of the current level before draining it.
Keep the first node of each level
The node popped at index 0 within a level's batch is, by BFS's left-to-right processing order, that level's leftmost node -- remember its value as the current candidate.
The last candidate wins
After the queue empties, whichever candidate was recorded on the final (deepest) level is the answer -- no explicit depth tracking of 'is this the deepest' is needed, since each level simply overwrites the last.
Solution & live demo
Edge cases
Root is both the first and last level's leftmost value.
BFS still records it correctly as that level's first-popped node -- a left-walk DFS would miss it.
Leftmost of the last level is simply the tree's normal bottom-left leaf.
Every level has exactly one node, so each level's candidate is trivially correct.