"Simple & small" ahh solution | Beats 100%.
IntuitionApproach
Find the smallest power of 2 that is strictly greater than n.
Return that power of 2, subtracting 1 as the result.
Complexity
Time complexity:
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
1. Find the smallest power of 2 that is strictly greater than n.
2. Return that power of 2, subtracting 1 as the result.
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:O(n)
<!-- 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 sol=0;
        for(int i=1;i<=n;++i){
            if(Math.pow(2,i)>n){
                sol =(int)Math.pow(2,i);
                break;
            }
        }
        return sol-1;
    }
}
```
['Java']