public class Solution {
public int maxDepth(TreeNode root) {
if(root == null) {
return 0;
}else {
int left = maxDepth(root.left)+1;
int right = maxDepth(root.right)+1;
return left>right?left:right;
}
}
}
104. Maximum Depth of Binary Tree
最新推荐文章于 2024-07-10 11:04:17 发布