Find Bottom Left Tree Value
Problem statement
Given a nonempty binary tree, return the value of its leftmost node on the deepest level.
Function
findBottomLeftValue(root: TreeNode) → intExamples
Example 1
root = [2,1,3]return = 1The deepest level contains 1 and 3; 1 is leftmost.
Example 2
root = [1,2,3,4,null,5,6,null,null,7]return = 7Seven is the only node on the deepest level.
Constraints
- The tree has between
1and10^5nodes. - Node values are 32-bit signed integers.