Skip to content

LC 0371 [M] Sum of Two Integers

Code with Senpai edited this page Mar 15, 2022 · 3 revisions

https://www.youtube.com/watch?v=gVUrDV4tZfY&ab_channel=NeetCode

class Solution {
    public int getSum(int a, int b) {
        while (b != 0) {
            int tmp = (a & b) << 1;
            a = a ^ b;
            b = tmp;
        }
        return a;
    }
}
Clone this wiki locally