Skip to content

Commit 78c499f

Browse files
committed
solve problem
1 parent 4c3fc36 commit 78c499f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

reverse-bits/delight010.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
func reverseBits(_ n: Int) -> Int {
3+
var number = n
4+
var result = 0
5+
6+
for i in 0..<32 {
7+
let bit = number & 1
8+
result = result << 1
9+
result = result | bit
10+
number = number >> 1
11+
}
12+
13+
return result
14+
}
15+
}
16+

0 commit comments

Comments
 (0)