3370. Smallest Number With All Set Bits
IntuitionEasy one!Approachwhile loop to count number of bits and returning the result as "2 raised to the power of count"-1.Complexity
Time complexity: O(logN)
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Easy one!
# Approach
<!-- Describe your approach to solving the problem. -->
while loop to count number of bits and returning the result as "2 raised to the power of count"-1.
# Complexity
- Time complexity: O(logN)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int smallestNumber(int n) {
        int c = 0;
        while(n>0)
        {
            n/=2;
            c++;
        }
        return (int)Math.pow(2,c)-1;
    }
}
```
['Java']