Hiring process8 levels
  1. 1 IQ Test
  2. 2 Additional Online Test (If Required)
  3. 3 Office Interview with Hiring Manager
  4. 4 Unpaid Test Task (Motivation Check)
  5. 5 Paid Test Task and Follow-Up Interview
  6. 6 Iterative Paid Test Tasks
  7. 7 Office Verification
  8. 8 Final Interview with the Founder

Problems > Numbers with K Set Bits > Editorial

Numbers with K Set Bits — Solution & Editorial

Back to the Problem

Binary digit DP: walk the bits of the bound; at each set bit, fixing it to 0 frees the lower bits, contributing C(remaining bits, needed ones). Combine over both bounds.

Complexity: O(log² N)

Watch out: Count in binary, not decimal; and remember to add 1 for the bound itself if it has exactly K bits.