Skip to content

Commit 0ffcf57

Browse files
committed
Sum Of Two Integers
1 parent fcf9aa7 commit 0ffcf57

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sum-of-two-integers/TonyKim9401.java

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

0 commit comments

Comments
 (0)