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.

  • Default User Avatar

    Based on the type of the argument (int), it can fit any number less than 2147483647 so considering the program with 10 should be fine.

  • Custom User Avatar

    What if the 'num' will contains more than 10 numbers?
    You need to determine the array size before