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 c5189fd commit 177c4a4Copy full SHA for 177c4a4
โsum-of-two-integers/Tessa1217.java
@@ -0,0 +1,26 @@
1
+/** +, - ๋ถํธ ์ฐ์ง ์๊ณ ๋ ์์ ํฉ ๊ตฌํ๊ธฐ */
2
+class Solution {
3
+
4
+ // ๋นํธ ์ฐ์ฐ์ผ๋ก ๊ณ์ฐ ์ํ
5
+ public int getSum(int a, int b) {
6
+ while (b != 0) {
7
+ // ์ผ์ชฝ ์ฌํํธํ์ฌ ์๋ฆฌ ์ฌ๋ฆผ์ ๋ํ ๊ณ์ฐ ์ํ
8
+ int bit = (a & b) << 1;
9
+ // XOR ์ฐ์ฐ์ผ๋ก ์๋ฆฌ ์ฌ๋ฆผ ์๋ ๋ง์ ์ํ
10
+ a = a ^ b;
11
+ b = bit;
12
+ }
13
+ return a;
14
15
16
+ /**
17
+ * ํ๋ฆฌ๊ธฐ๋ ํ์ง๋ง, ์ด๋ฐ ์์ ํธ๋ฒ์ผ ๊ฒ ๊ฐ์...?
18
+ * Class Integer ๋ด๋ถ์ sum ์ฐ์ฐ: Adds two integers together as per the + operator.
19
+ * + operator ์ด๋ค๊ณ ๋์ด์์...
20
+ * */
21
+// public int getSum(int a, int b) {
22
+// return Integer.sum(a, b);
23
+// }
24
25
+}
26
0 commit comments