---
title: "190. Reverse Bits"
url: "https://laigary.com/interview/coding/190-reverse-bits"
type: "note"
section: "coding"
date: "2024-03-10"
updated: "2024-03-10"
tags: ["Bit Manipulation"]
---

# 190. Reverse Bits

[190\. Reverse Bits](https://leetcode.com/problems/reverse-bits/)

```python
class Solution:
    def reverseBits(self, n: int) -> int:
        res = 0
        power = 31
        
        while n:
            res += (n & 1) << power
            n = n >> 1
            power -= 1
        
        return res
```
