有些事情是不能告诉别人的,有些事情是不必告诉别人的,有些事情是根本没有办法告诉别人的,而且有些事情是,即使告诉了别人,你也会马上后悔的。——罗曼罗兰

class Solution {
public int countNodes(TreeNode root) {
if(root==null) return 0;
int l = 0;
int r = 0;
TreeNode lt = root;
while(lt.left!=null){
lt = lt.left;
l++;
}
TreeNode rt = root;
while(rt.right!=null){
rt = rt.right;
r++;
}
if(l==r) return (int)Math.pow(2,l+1)-1;
return 1 + countNodes(root.left) + countNodes(root.right);
}
}