mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-04 16:12:47 +08:00
11 lines
151 B
Go
11 lines
151 B
Go
package leetcode
|
|
|
|
func reverseBits(num uint32) uint32 {
|
|
var res uint32
|
|
for i := 0; i < 32; i++ {
|
|
res = res<<1 | num&1
|
|
num >>= 1
|
|
}
|
|
return res
|
|
}
|