二叉树最大深度
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 } }
二叉树的前中后序遍历