异或运算能做出没有进位的加法,而与运算可以得到加法的进位
class Solution {
public int add(int a, int b) {
while(b!=0){
int c = (a & b) << 1;
a ^= b;
b = c;
}
return a;
}
}
二叉树的递归总会有极简而又神奇的写法
class Solution {
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
if(root==null||p==root||q==root) return root;
TreeNode left = lowestCommonAncestor(root.left,p,q);
TreeNode right = lowestCommonAncestor(root.right,p,q);
if(left==null) return right;
if(right==null) return left;
return root;
}
}



