Smallest Number With All Set Bits
You are given a positive number n.
Return the smallest number x greater than or equal to n, such that the binary representation of x contains only set bits.
Example 1
Input
n = 5Output
7The binary representation of 7 is
"111".Example 2
Input
n = 10Output
15The binary representation of 15 is
"1111".Constraints
- 1 <= n <= 1000