我有一些案例通过这段代码,但其他人都失败了..这是我的逻辑还是if语句的顺序..请帮助..使用practiceitcs网站
public int countLeftNodes() {
return countLeftNodes(overallRoot);
}
private int countLeftNodes(IntTreeNode root){
int count = 0;
if (root== null) return count;
if (root.right == null && root.left == null)
return count;
if(root.right != null) count += countLeftNodes(root.left);
if (root.left!= null)
count += 1 + countLeftNodes(root.left);
return count;
}