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 baf6fe2 commit 6cbb599Copy full SHA for 6cbb599
โreverse-bits/soobing.tsโ
@@ -0,0 +1,22 @@
1
+/**
2
+ *
3
+ * ๋ฌธ์ ์ค๋ช
4
+ * - 32๋นํธ unsigned ์ ์์ ๋นํธ ์์๋ฅผ ๋ค์ง์ด์ ๋ค์ ์ ์๋ก ๋ฐํํ๋ ๋ฌธ์
5
6
+ * ์์ด๋์ด
7
+ * - ๋นํธ ์ฐ์ฐ์ ์ดํดํ๊ณ , O(1)์์๊ฐ๋๋ฐ ์์๋ฅผ ๋๋ฉด ์ข์ ๊ฒ ๊ฐ์.
8
9
+ * ๋นํธ ์ฐ์ฐ
10
+ * >>>, >>, <<, &, |
11
+ * - signed, unsigned ์ฐ์ฐ
12
+ */
13
+function reverseBits(n: number): number {
14
+ let result = 0;
15
+ for (let i = 0; i < 32; i++) {
16
+ result <<= 1;
17
+ result |= n & 1;
18
+ n >>>= 1;
19
+ }
20
+
21
+ return result >>> 0;
22
+}
0 commit comments