LintCode 1.A+B的问题

描述

给出两个整数 ab , 求他们的和。

答案

public class Solution {/*** @param a: An integer* @param b: An integer* @return: The sum of a and b */public int aplusb(int a, int b) {// write your code hereint m = a^b;            // 保留值不同的位int n = (a&b) << 1;     // 值相同的位进1if(n != 0) {m = aplusb(m, n);}return m;}
}

转载于:https://www.cnblogs.com/wuxie0ne/p/10672725.html

LintCode 1.A+B的问题相关推荐

  1. LintCode 249. 统计前面比自己小的数的个数

    给定一个整数数组(下标由 0 到 n-1, n 表示数组的规模,取值范围由 0 到10000).对于数组中的每个 ai 元素,请计算 ai 前的数中比它小的元素的数量. 注意事项 We suggest ...

  2. LintCode: Max Tree

    题目 Given an integer array with no duplicates. A max tree building on this array is defined as follow ...

  3. 【LintCode: 3. 统计数字】算法题解析

    这是一道来自LintCode的算法题目,本文用C++来解答这道题,链接为: https://www.lintcode.com/problem/digit-counts/description 题目描述 ...

  4. 关于爬楼梯的lintcode代码

    讲真的,这个我只会用递归去做,但是lintcode上面超时,所以只有在网上找了个动态规划的,虽然这个程序懂了,但是我觉得还是挺不容易的真正弄懂的话-- class Solution { public: ...

  5. lintcode: k Sum 解题报告

    K SUM My Submissions http://www.lintcode.com/en/problem/k-sum/ 题目来自九章算法 13% Accepted Given n distinc ...

  6. LintCode Longest Increasing Continuous Subsequence

    原题链接在这里:http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence/ 题目: Give an in ...

  7. lintcode 滑动窗口的最大值(双端队列)

    题目链接:http://www.lintcode.com/zh-cn/problem/sliding-window-maximum/# 滑动窗口的最大值 给出一个可能包含重复的整数数组,和一个大小为  ...

  8. leetcode 293.Flip Game(lintcode 914) 、294.Flip Game II(lintcode 913)

    914. Flip Game https://www.cnblogs.com/grandyang/p/5224896.html 从前到后遍历,遇到连续两个'+',就将两个加号变成'-'组成新的字符串加 ...

  9. LintCode 402: Continuous Subarray Sum

    LintCode 402: Continuous Subarray Sum 题目描述 给定一个整数数组,请找出一个连续子数组,使得该子数组的和最大.输出答案时,请分别返回第一个数字和最后一个数字的下标 ...

最新文章

  1. 基于四元数互补滤波的无人机姿态解算
  2. 帆软填报增加记录提交成功后没有_大病医疗填报图解
  3. python适合做后端开发吗-pythonWeb后端开发好呢?还是从事网络爬虫比较好呢?
  4. JAVA 将图片转换为Base64编码
  5. 吉林大学不如温州大学,泰晤士最新世界大学排名引发争议
  6. 我也想对广大程序员说一些话
  7. 树莓派zero+mysql_关于树莓派zero的系统安装配置部署
  8. java如何操作视图
  9. MATLAB调用C语言程序—一个简单的例子
  10. x265 编码一行,以及vbv上溢/下溢之后的处理
  11. 单例模式-八种方法代码详解
  12. 13个有意思的网站,你一定要看
  13. Laravel sms短信验证码
  14. 关于linux fc多路径巡检
  15. 南京广义软件:Android lunch分析以及产品分支构建
  16. app常见专项测试点
  17. Bt(宝塔面板)phpmyadmin打不开的解决办法
  18. Excel:制作下拉选项
  19. 一个运动控制系统的实例
  20. 京东方数字艺术产业论坛:感受科技的艺术之美

热门文章

  1. 21、C#里面类的创建和使用
  2. Log4J xml配置
  3. react-router的基础知识
  4. 设计模式学习(五) 适配器模式
  5. Lync Server 2010迁移至Lync Server 2013部署系列21:Lync 2013边缘第二台服务器配置
  6. Windows Server 2008 R2 活动目录服务部署 (一)
  7. cygwin中 unable get setup.ini from... 的错误问题
  8. Cassandra-Java(增删查改)
  9. 斐波那契公约数的相关证明
  10. 发送电子邮件模块smtplib