Data Structures & AlgorithmsHardCodeforces Div2 B · TCS NQT

How many integers x with 1 ≤ x < 300 have the same decimal digit sum as x + 1?

  1. A. 4
  2. B. 0
  3. C. -3
  4. D. 30

Correct answer: B. 0

Adding 1 to x changes the digit sum by +1 when the last digit is not 9, and by 1 − 9t when t trailing 9s roll over. Counting the pairs whose last digit is not 9 gives a different count, since carries can also preserve the sum.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic