> For the complete documentation index, see [llms.txt](https://chiragjain.gitbook.io/neetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chiragjain.gitbook.io/neetcode/190-reverse-bits/code.md).

# CODE

```python
class Solution:
    def reverseBits(self, n: int) -> int:
        # Get the LSB and keep appending to result.
        # while result shifts to the left the lsb is 
        # always appended as result's so over time by left 
        # shift it becomes msb
        result = 0
        for _ in range(32):
            result = result << 1
            result = result | n & 1
            n = n >> 1
        return result
        
```
