Given the root of a binary tree, you need to find the leftmost value in the bottom row of the tree.
Think of it as looking at a binary tree from above and wanting to know what value sits at the leftmost position of the deepest level. The tree is guaranteed to have at least one node, so there will always be a bottom-left value to find.
Goal: Return the leftmost value in the last row of the binary tree.
Input: Root node of a binary tree
Output: Integer value of the leftmost node in the deepest level
Example: In a tree where the bottom row contains [7, 4], return 7 since it's the leftmost value in that row.
Input & Output
Visualization
Time & Space Complexity
Visit each node once to collect data, then scan through collected nodes
Store information for all nodes in the tree
Constraints
- The number of nodes in the tree is in the range [1, 104]
- -231 โค Node.val โค 231 - 1
- It's guaranteed that the tree has at least one node