This a new version of this post in order to isolate the programming question from the probability question.
I want to store a number of e.g. 25 randomly generated numbers between 1 and 365 in an array. But i need to keep track of duplicates. Here's how i was thinking of doing it:
create 4 arrays: a master array, an array for 2 duplicates, an array for 3 duplicates and one for more than 3 duplicates
add each generated number one by one into the master array. But before doing so, loop through the array to see if it's in there already. If so, add it to the second array, but before doing so repeat the above process and so on
at the end of the process i could count the non-null values in each array to know how many unique numbers i have, how many came up twice etc
it doesn't seem to be a very efficient algorithm. Any suggestions to improve it?
Can my suggested approach be considered to be Big O(n) i.e. linear?