#190
Reverse Bits
easy· Bit Manipulationruns: 0Reverse the bits of a given 32-bit unsigned integer.
sign in to paste and practice your own solution
wpm 0acc 100%time 0:000 / 192
class Solution:
def reverseBits(self, n: int) -> int:
result = 0
for _ in range(32):
result = (result << 1) | (n & 1)
n >>= 1
return result
click the box to focus · tab inserts 4 spaces · backspace to correct · esc to pause
desktop only
codedrill is a typing game and needs a real keyboard. open this on a laptop or desktop to practice.
you can still browse problems and sections from your phone.