栈 递归
作者:互联网
二叉树最大深度
https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/
/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func maxDepth(root *TreeNode) int { if root == nil { return 0 } l := maxDepth(root.Left) r := maxDepth(root.Right) if l > r { return l + 1 } else { return r + 1 } }
二叉树的前中后序遍历
标签:return,递归,int,maxDepth,TreeNode,root,二叉树 来源: https://www.cnblogs.com/rsapaper/p/16180388.html