LintCode 1. A + B 问题 ☆
来源:互联网 发布:oppor11t网络切换破解 编辑:程序博客网 时间:2024/06/07 09:30
代码:
public class Solution { /* * @param : An integer * @param : An integer * @return: The sum of a and b */ public int aplusb(int a, int b) { // write your code here // 方法一:return a-(b)*(-1); // 方法二: if(b == 0) return a; int XORresult = a ^ b; int carry = (a & b)<<1; return aplusb(XORresult,carry); }};
方法一:用两个负号
方法二:异或来代替加法 注意处理进位
阅读全文
0 0
- LintCode 1. A + B 问题 ☆
- LintCode | 1. A + B 问题
- LintCode 1.A + B 问题
- LintCode-A + B 问题
- Lintcode A+B问题
- LintCode-A + B 问题
- LintCode A+b问题
- LintCode-A + B 问题
- lintcode -- A+B问题
- Lintcode:A + B 问题
- [LintCode]1.A + B 问题 位运算
- LintCode之A+B问题
- Lintcode 1 A + B 问题
- 【LintCode】1、A + B问题
- [Lintcode] #1 A + B 问题
- LintCode-(1)A + B 问题
- LintCode-剑指Offer-(1)A+B问题
- lintcode刷题 A + B 问题 位运算
- Android的SlidingMenu 常用属性介绍
- android数据绑定框架DataBinding使用
- 空手套白狼之——兼职中介
- 基础工具---校验密码规则
- java回调形象描述
- LintCode 1. A + B 问题 ☆
- 关于.so库文件引入项目导致crash的若干问题总结
- 记录 Parameter with that position [1] did not exist; nested exception is java.lang.IllegalArgumentExce
- 15算法课程 290. Word Pattern
- 不到40行代码构建正则表达式引擎
- CSS3动画特效详解
- ES6 Promise
- Android动画之补间动画
- Akka(43): Http:SSE-Server Sent Event