MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / reverseBits

Function reverseBits

reverse_bits_190/solution.go:3–15  ·  view source on GitHub ↗
(num uint32)

Source from the content-addressed store, hash-verified

1package reverse_bits_190
2
3func reverseBits(num uint32) uint32 {
4 var res uint32
5 for i := 0; i < 32; i++ {
6 res <<= 1
7
8 // num & 1 gives last digit of num
9 res |= num & 1
10
11 num >>= 1
12 }
13
14 return res
15}

Callers 1

Test_reverseBitsFunction · 0.85

Calls

no outgoing calls

Tested by 1

Test_reverseBitsFunction · 0.68