We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f119d27 commit f0acdddCopy full SHA for f0acddd
EASY/src/easy/SumofTwoIntegers.java
@@ -0,0 +1,13 @@
1
+package easy;
2
+
3
+public class SumofTwoIntegers {
4
+//This post is very helpful: http://stackoverflow.com/questions/9070937/adding-two-numbers-without-operator-clarification
5
+ //I also shared my solution here: https://discuss.leetcode.com/topic/49870/one-liner-with-detailed-explanation
6
+ public int getSum(int a, int b) {
7
+ if(b == 0) return a;
8
+ int sum = a^b;
9
+ int carry = (a&b) << 1;
10
+ return getSum(sum, carry);
11
+ }
12
13
+}
0 commit comments