每日一题ing,今天是个easy题104. Maximum Depth of Binary Tree
class Solution {
public int maxDepth(TreeNode root) {
return getDepth(root);
}
public int getDepth(TreeNode root) {
if(root==null){
return 0;
}
int leftDepth=getDepth(root.left);
int rightDepth=getDepth(root.right);
int wholeDepth=Math.max(leftDepth,rightDepth)+1;
return wholeDepth;
}
}