Data Structures & AlgorithmsHardCAT · TCS NQT

Problem: How many 5-digit numbers (10000–99999) have digits that sum to exactly 6 and begin with the digit 1?

  1. A. 126
  2. B. 56
  3. C. 84
  4. D. 35

Correct answer: B. 56

After the leading 1, four digits sum to 5: C(5 + 3, 3) = 56 (no digit can exceed 9 here). C(9,4) = 126 and C(9,3) = 84 use the wrong stars-and-bars parameters, and 35 forces every digit to be at least 1.

More Coding Interview Problems questions

Exams that ask this topic