Skip to content

Commit 58bce35

Browse files
author
Jinbeom
committed
Sum of Two Integers Solution
1 parent b2939fc commit 58bce35

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sum-of-two-integers/kayden.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
// time: O(1)
3+
// space: O(1)
4+
public int getSum(int a, int b) {
5+
while (b != 0) {
6+
int tmp = (a & b) << 1;
7+
a = a ^ b;
8+
b = tmp;
9+
}
10+
return a;
11+
}
12+
}

0 commit comments

Comments
 (0)