Data Structures & AlgorithmsHardGATE CS

How many integers n with 1 ≤ n ≤ 999 have digit sum exactly 12 and contain no digit 0 (in their usual decimal form, without leading zeros)?

  1. A. 66
  2. B. 73
  3. C. 52
  4. D. 59

Correct answer: D. 59

Enumerate n and test both conditions: 59 numbers qualify, of which 52 have three digits. Dropping the no-zero condition gives 73.

More Coding Interview Problems questions

Exams that ask this topic