Skip to content

Commit

Permalink
Sum of Two Integers Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinbeom committed Oct 4, 2024
1 parent b2939fc commit 58bce35
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sum-of-two-integers/kayden.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution {
// time: O(1)
// space: O(1)
public int getSum(int a, int b) {
while (b != 0) {
int tmp = (a & b) << 1;
a = a ^ b;
b = tmp;
}
return a;
}
}

0 comments on commit 58bce35

Please sign in to comment.