thiagowfx's avatar

Β¬ just serendipity πŸ€ (not just serendipity)

LeetCode #3370: Smallest Number With All Set Bits

β€’ 25 words β€’ 1 min

LeetCode #3370: Smallest Number With All Set Bits:

python
class Solution:
    def smallestNumber(self, n: int) -> int:
        return n | (1 << n.bit_length()) - 1