/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class Solution {
public int maxDepth(TreeNode root) {
if(root == null) return 0;
int l = maxDepth(root.left);
int r = maxDepth(root.right);
return 1+ Math.max(l,r);
}
}
104. Maximum Depth of Binary Tree
最新推荐文章于 2020-04-07 01:17:51 发布