title: Count frequencies of all elements in array in O(1) extra space and O(n) time
body: <p>Problem Description: I found this problem in my Algorithms Assignment .
  It wants me to find the frequencies of all the elements of an array in O(n) time and O(1) space.</p>
  
  <p>Array Can be anything like
  Ar[]={1,6,3,78,4,6,1}</p>
  
  <p>After Thinking a little bit i came up with this approach:</p>
  
  <ol>
  <li>Iterating the array and finding the max element.( O(n) time)</li>
  <li>Creating a new array of the size= max element  ( O(1) space)</li>
  <li>Iterating over the original array and storing the frequencies at the indices of the new array (O(n) time).</li>
  </ol>
  
  <p>I have a doubt regarding step 2.
  After finding the max element(say m) in Step 1 i am making a new array of size m.
  does thing array occupies O(1) space ? if not please explain</p>