lc-go/solutions/33/q3370/solution.go

13 lines
239 B
Go

// Package q3370 implements a solution for https://leetcode.com/problems/smallest-number-with-all-set-bits/
package q3370
func smallestNumber(n int) int {
i := 0
for n > 0 {
n >>= 1
i++
}
return 1<<i - 1
}
var _ = smallestNumber