首页 > 代码库 > 104. Maximum Depth of Binary Tree

104. Maximum Depth of Binary Tree

思路:纯递归。

 

public class Solution {    public int maxDepth(TreeNode root) {        if(root==null)        {            return 0;        }        return Math.max(maxDepth(root.left),maxDepth(root.right))+1;    }}

 

104. Maximum Depth of Binary Tree