思路
- 递归,比较简单
- 遍历,堆栈或者层序遍历
代码
public class Solution {
public int TreeDepth(TreeNode root) {
if(root==null){return 0;}
return 1+Math.max(TreeDepth(root.left),TreeDepth(root.right));
}
} 
public class Solution {
public int TreeDepth(TreeNode root) {
if(root==null){return 0;}
return 1+Math.max(TreeDepth(root.left),TreeDepth(root.right));
}
}