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 89cf4e9 commit 2d87ed6Copy full SHA for 2d87ed6
reverse-bits/easyone-jwlee.go
@@ -0,0 +1,20 @@
1
+// 풀이
2
+// result 가장 오른쪽 값에 num의 값을 추가하면서 왼쪽으로 밀어 reverse 처리.
3
+
4
+// TC
5
+// for문은 무조건 32회만 돌기때문에 O(1)
6
7
+// SC
8
+// 추가적인 공간 사용량은 일정하므로 0(1)
9
10
+func reverseBits(num uint32) uint32 {
11
+ result := uint32(0)
12
+ for i := 0; i < 32; i++ {
13
+ result <<= 1
14
+ if num%2 == 1 {
15
+ result++
16
+ }
17
+ num >>= 1
18
19
+ return result
20
+}
0 commit comments