[LeetCode]371. Sum of Two Integers
来源:互联网 发布:算法的概念一等奖ppt 编辑:程序博客网 时间:2024/06/05 08:46
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) { //将十机制加法转化为二进制加法 //非进位项用异或获得,进位项用与获得,进位项向左移位获得真正的进位数 //重复这个操作直到不能再进位 if(b == 0) return a; int nocarrynum = a ^ b; int carrynum = (a & b)<<1; return getSum(nocarrynum, carrynum); }};
0 0
- LeetCode 371. Sum of Two Integers
- 371. Sum of Two Integers LeetCode OJ
- [Leetcode]371. Sum of Two Integers
- LeetCode - 371. Sum of Two Integers
- <LeetCode OJ> 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
- 371. Sum of Two Integers(Leetcode)
- leetcode 371. Sum of Two Integers
- 【leetcode】371. Sum of Two Integers【E】
- [leetcode] 371. Sum of Two Integers
- leetcode.371. Sum of Two Integers
- 371. Sum of Two Integers--LeetCode Record
- LeetCode—371. Sum of Two Integers
- Leetcode 371. Sum of Two Integers
- LeetCode 371. Sum of Two Integers
- 10092
- 调参
- sdwebimage框架
- Caffe:Windows(64位)+VS2013下的Caffe(CPU Only)安装配置
- Linux 下使用sendmail搭建邮件服务器
- [LeetCode]371. Sum of Two Integers
- java实现单词倒序输出
- linux 信号signal和sigaction理解
- ios单例GCD实现方法
- 12本精彩的Linux书籍
- 10.9
- PHP 开启 opcache 方法
- Posix多线程编程—线程属性
- java对ftp操作