public class Solution {
    public int GetSum(int a, int b) {
        return b == 0 ? a : GetSum(a ^ b, (a & b) << 1);
    }
}

https://leetcode.com/problems/sum-of-two-integers/#/description

 

补充一个python的实现:

1 class Solution:
2     def getSum(self, a: int, b: int) -> int:
3         l = [a,b]
4         result = sum(l)
5         return result

 

posted on 2017-04-19 11:00  Sempron2800+  阅读(124)  评论(0编辑  收藏  举报