3821. Find Nth Smallest Integer With K One Bits
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. Example 1: Input: n = 4, k = 2 Output: 9 Explanation: The 4 smallest positive integers that have exactly k = 2 ones in their binary representations are: - 3 = 112 - 5 = 1
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start