解题思路:
使用无符号类型来防止溢出,利用位运算进行两整数的求和,熟悉计组的朋友一定更加清楚,想要了解清楚的可以参考官方题解,代码如下:
class Solution {
public:
int getSum(int a, int b) {
while (b != 0) {
unsigned int carry = (unsigned int)(a & b) << 1;
a = a ^ b;
b = carry;
}
return a;
}
};


![LeetCode 371 两整数之和[位运算] HERODING的LeetCode之路 LeetCode 371 两整数之和[位运算] HERODING的LeetCode之路](http://www.mshxw.com/aiimages/31/272074.png)
