A + B Problem
2016-07-06 02:21
344 查看
Write a function that add two numbers A and B. You should not use
分析:
典型的Bit Operation.
+or any arithmetic operators.
分析:
典型的Bit Operation.
class Solution { /* * param a: The first integer * param b: The second integer * return: The sum of a and b */ public int aplusb(int a, int b) { if (a == 0) return b; int sum = a ^ b; int carry = (a & b) << 1; return aplusb(carry, sum); } };
相关文章推荐
- 关键字
- tomcat源码解析(二)--web.xml文件的解析
- Trailing Zeros
- 简单题:不等式(知道了运算符号算是字符可以定义为char类型)待解决
- How do I divide matrix elements by column sums in MATLAB?
- Linux上创建和更改硬链接和符号链接
- 【我的《冒号课堂》学习笔记】设计原则(2)依赖原则
- RHEL 7.0系统安装配置图解教程
- Reverse Pairs
- The Concept of Indistinguishability under Chosen Plaintext Attack (IND-CPA)
- UITableView滚动时NSTimer不执行
- Jekyll搭建本地环境
- STM32 之GPIO
- 用 pytube 爬取 youtube 视频
- Android 中自动同步的机制的简单的demo,例如订单同步,商品同步,会员同步,操作同步
- 20160706
- CMake 入门介绍和实例
- 292. Nim Game--LeetCode Record
- JAVA程序员一定知道的优秀第三方库(2016版)
- CentOS 7.0系统安装配置图解教程