104. Maximum Depth of Binary Tre

2018-07-30  本文已影响0人  becauseyou_90cd

https://leetcode.com/problems/maximum-depth-of-binary-tree/description/
解题思路:用preorder方法

代码:
class Solution {
public int maxDepth(TreeNode root) {

    if(root == null) return 0;
    return 1 + Math.max(maxDepth(root.left), maxDepth(root.right));
}

}

上一篇 下一篇

猜你喜欢

热点阅读