leetcode 371 Sum of Two Integers
来源:互联网 发布:gta5韩国美女捏脸数据 编辑:程序博客网 时间:2024/06/09 14:30
Problem:
不用+-将两个数相加。
Solution:
两个数相加,可以当做不进位的数加上进位的数。
a^b得到了不算进位时的结果。
(a&b)<<1 得到了应该进的位。
class Solution {public: int getSum(int a, int b) { return (b==0) ? a : getSum(a^b, (a&b)<<1); }};
1 0
- LeetCode 371 Sum of Two Integers
- [leetcode-371]Sum of Two Integers(java)
- LeetCode[371] Sum of Two Integers
- LeetCode 371 : Sum of Two Integers(Java)
- leetcode NO.371 sum of two integers
- LeetCode#371 Sum of Two Integers
- leetcode 371 Sum of Two Integers C++
- LeetCode 371: Sum of Two Integers 题解
- LeetCode(371) Sum of Two Integers
- leetcode:bits:Sum of Two Integers(371)
- [LeetCode-371]Sum of Two Integers(C)
- LeetCode 371:Sum of Two Integers
- LeetCode 371 Sum of Two Integers
- Leetcode 371 Sum of Two Integers
- leetcode-371-Sum of Two Integers
- leetcode 371 Sum of Two Integers
- [Leetcode] #371 Sum of Two Integers
- Leetcode #371 Sum of Two Integers
- JAVA_Base
- 神经网络之损失函数:方差损失和互熵损失
- Hdu 1350 Taxi Cab Scheme【最小路径覆盖】
- 学习Flask 之一 环境安装
- Python实现定时任务
- leetcode 371 Sum of Two Integers
- 队花的烦恼一
- 《线上幽灵》
- defer、async属性以及JS异步加载并执行解决方案
- LeetCode之Merge two sorted array
- defer、async属性以及JS异步加载并执行解决方案
- [翻译自MOS文章]怎么在OGG 12c版本中把replicat进程重新定位到之前的trail文件位置上?
- 如何查看Struts2的action情况
- [BZOJ1770][Usaco2009 Nov]lights 燈(高斯消元)