1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package main
- func maxDepthIter(curr *TreeNode, depth int) int {
- if curr == nil {
- return depth
- }
- return maxInt(maxDepthIter(curr.Left, depth+1), maxDepthIter(curr.Right, depth+1))
- }
- func maxDepth(root *TreeNode) int {
- return maxDepthIter(root, 0)
- }
|