We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cddf0cf commit 9093505Copy full SHA for 9093505
sum-of-two-integers/minji-go.java
@@ -0,0 +1,17 @@
1
+/**
2
+ * <a href="https://leetcode.com/problems/sum-of-two-integers/">week9-4. sum-of-two-integers</a>
3
+ * <li>Description: Given two integers a and b, return the sum of the two integers without using the operators + and -.</li>
4
+ * <li>Topics: Math, Bit Manipulation </li>
5
+ * <li>Time Complexity: O(1), Runtime 0ms </li>
6
+ * <li>Space Complexity: O(1), Memory 40.51MB </li>
7
+ */
8
+class Solution {
9
+ public int getSum(int a, int b) {
10
+ while (b != 0) {
11
+ int tmp = (a & b) << 1;
12
+ a = (a ^ b);
13
+ b = tmp;
14
+ }
15
+ return a;
16
17
+}
0 commit comments