Tap here to switch tabs
Problem
Submissions

Problem: Find Nth Smallest Integer With K One Bits

Try to solve the Find Nth Smallest Integer With K One Bits problem.

Statement

Given two positive integers n and k, return the nth smallest positive integer that has exactly k set bits in its binary representation.

Constraints:

  • 1≤1 \leq n ≤250\leq 2^{50}

  • 1≤1 \leq k ≤50\leq 50

  • The answer is strictly less than 2502^{50}.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Nth Smallest Integer With K One Bits

Try to solve the Find Nth Smallest Integer With K One Bits problem.

Statement

Given two positive integers n and k, return the nth smallest positive integer that has exactly k set bits in its binary representation.

Constraints:

  • 1≤1 \leq n ≤250\leq 2^{50}

  • 1≤1 \leq k ≤50\leq 50

  • The answer is strictly less than 2502^{50}.