您的位置:首页 > 其它

104. Maximum Depth of Binary Tree

2016-02-10 23:07 148 查看
深度优先搜索,迭代求子树深度

public class Solution {

    public int maxDepth(TreeNode root) {

        if(root==null){

            return 0;

        }

        int left=maxDepth(root.left);

        int right=maxDepth(root.right);

        return Math.max(left,right)+1;

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: