Skip to content

Latest commit

 

History

History
executable file
·
19 lines (11 loc) · 339 Bytes

190.md

File metadata and controls

executable file
·
19 lines (11 loc) · 339 Bytes

190. Reverse Bits

When I first see this problem, will the value be overflow?

the easiest solution for this problem is just tranfer to binary and reverse

PLEASE USE BIT OPERATION

1101 & 1 => 1 (res<<1+1) 1101 >> 1 => 110

110 & 1 => 0 (res<<1+0) 110 >> 1 => 11

therefore we can know our algorithm is that

res<<1 + n&1 n >> 1