Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.
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.
What if the 'num' will contains more than 10 numbers?
You need to determine the array size before