美文网首页
371. Sum of Two Integers

371. Sum of Two Integers

作者: 安东可 | 来源:发表于2018-03-26 22:38 被阅读4次

    371. Sum of Two Integers
    【思路】:

    1. 位运算
    2. [leetcode] 371. Sum of Two Integers 解题报告
        int getSum(int a, int b) {
                int ans = a ^ b;
        int c = a & b;
        while(c != 0) {
            c <<= 1;
            int ans_prim = ans ^ c;
            c = ans & c;
            ans = ans_prim;
        }
        return ans;
        }
    

    相关文章

      网友评论

          本文标题:371. Sum of Two Integers

          本文链接:https://www.haomeiwen.com/subject/ehudcftx.html