title: storing random values in arrays considering duplicates
body: <p>This a new version of  <a href="https://stackoverflow.com/questions/4990164/estimating-the-probability-of-3-people-sharing-a-birthday">this post</a> in order to isolate the programming question from the probability question.</p>
  
  <p>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:</p>
  
  <ul>
  <li><p>create 4 arrays: a master array, an array for 2 duplicates, an array for 3 duplicates and one for more than 3 duplicates</p></li>
  <li><p>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</p></li>
  </ul>
  
  <p>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</p>
  
  <p>it doesn't seem to be a very efficient algorithm. Any suggestions to improve it?</p>
  
  <p>Can my suggested approach be considered to be Big O(n) i.e. linear?</p>