![]() |
VOOZH | about |
Given two non-negative integers m and k. The problem is to find the m-th smallest number having k number of set bits.
Constraints: 1 <= m, k.
Examples:
Input : m = 4, k = 2 Output : 9 (9)10 = (1001)2, it is the 4th smallest number having 2 set bits. Input : m = 6, k = 4 Output : 39
Approach: Following are the steps:
Output:
39
Time Complexity: O(m)
Space Complexity: O(1)