371. Sum of Two Integers也许是最简洁易懂的做法了
来源:互联网 发布:如何查看笔记本mac地址 编辑:程序博客网 时间:2024/06/06 04:16
Calculate the sum of two integers a and b, but you are not allowed to use the operator +
and -
.
Example:
Given a = 1 and b = 2, return 3.
实现:
class Solution {
public:
int getSum(int a, int b) {
while (b){
int x = a ^ b, y = (a & b) << 1;
a = x; b = y;
}
return a;
}
};
0 0
- 371. Sum of Two Integers也许是最简洁易懂的做法了
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- jQuery插件编写
- 关于Logstash中grok插件的正则表达式例子
- UVA - 1623 - Enter The Dragon
- Android收藏好文章
- 深度学习(Deep Learning)读书思考三:正则化
- 371. Sum of Two Integers也许是最简洁易懂的做法了
- 算法导论梳理(一)
- Servlet学习笔记(使用IDE开发Servlet)
- ReflectionUtils的findField方法
- 只出现一次的数字
- 代码获取storyboard中定义的UIViewController
- WPF注册依赖属性—依赖属性值继承方法
- 常见计算机网络拓扑
- mdd的烦恼