Skip to content

Commit 18a30cc

Browse files
committed
solve sum of two integers
1 parent d041640 commit 18a30cc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sum-of-two-integers/sora0319.java

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

0 commit comments

Comments
 (0)