#3821
Find Nth Smallest Integer With K One Bits
hard · 34.2% accepted · 66 likes · top 12%
math · bit manipulation · combinatorics
Description
You are given two positive integers n and k.
Return an integer denoting the nth smallest positive integer that has exactly k ones in its binary representation. It is guaranteed that the answer is strictly less than 250.
Solution