Skip to content

Commit c6de872

Browse files
committed
Solution for: sum of two integers
1 parent dbd7d34 commit c6de872

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/leetcode/SumofTwoIntegers.java

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package leetcode;
2+
3+
public class SumofTwoIntegers {
4+
5+
public static void main(String[] args) {
6+
// TODO Auto-generated method stub
7+
8+
}
9+
10+
public int getSum(int a, int b) {
11+
while(b!=0){
12+
int carry = a & b;
13+
a = a^b;
14+
b = carry<< 1;
15+
}
16+
return a;
17+
}
18+
19+
}

0 commit comments

Comments
 (0)