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∎
Connections
Shared tags