Ad
  • Default User Avatar

    10 is NOT the maximum number of digits in the number, but the number of (possible) different digits in a number. And there are only ten: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
    Each of the 10 array elements is used to count the number of occurances of the respective number, e.g. digitsCount[5] counts how many occurances of 5 are in the input.