class Solution:
    def reverseBits(self, n: int) -> int:
        s = bin(n)[2:]
 
        arr = list(s)
 
        for i in range(32 - len(arr)):
            arr.insert(0, 0)
 
        arr = arr[::-1]
 
        res = 0
        j = 0
 
        # Convert the binary representation back into a number
        for i in range(len(arr) - 1, -1, -1):
            if arr[j] == '1':
                res = (2 ** i) + res
 
            j += 1
 
        return res

References

https://leetcode.com/problems/reverse-bits/submissions/884050295/