Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions LeetCode/Reverse Bits/reversebits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Solution:
def reverseBits(self, n: int) -> int:
# convert the number into 32 bit binary
bin_num = '{:032b}'.format(n)
# reverse the string and convert into integer using inbuilt method
return int(bin_num[::-1], 2)