The number of nodes in the tree is in the range [1, 10^4].
-2^31 <= Node.val <= 2^31 - 1
解ι‘
Runtime: 0 ms, faster than 100%
Memory Usage: 5.1 MB, less than 100%
/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */funcfindBottomLeftValue(root *TreeNode) int { ans := root.Val depth :=0// η΄ιηζ‘ηζ·±εΊ¦var helper func(*TreeNode, int) helper =func(node *TreeNode, dep int) {if node ==nil { return }if dep > depth { ans = node.Val depth = dep }helper(node.Left, dep +1) // ζ―欑ι½ε ιζ·ε·¦ιοΌηζ‘ζζζ―ζε·¦ιηη―ι»helper(node.Right, dep +1) }helper(root, 0)return ans}