package sword;
public class tmp1 {
public static void main(String[] args) {
System.out.println(19 & 20);
}
int count = 1;
int max = 0;
public int TreeDepth(TreeNode pRoot) {
if(pRoot==null)return 0;
if (pRoot.left != null) {
count++;
TreeDepth(pRoot.left);
} else
if (count > max)
max = count;
if (pRoot.right != null) {
count++;
TreeDepth(pRoot.right);
} else {
if (count > max)
max = count;
count--;
}
return max;
}
public class TreeNode {
int val = 0;
TreeNode left = null;
TreeNode right = null;
public TreeNode(int val) {
this.val = val;
}
}
}
求二叉树深度
最新推荐文章于 2022-09-26 10:08:39 发布