title: Algorithm in saving elements in array maintaining order
body: <p>I have on one random number generator which generates number between <code>1 to k</code>. Also i have array of <code>int</code> type (i.e <code>int[]</code>) ,whose size is <code>N</code> , where <code>k</code> is smaller than N . </p>
  
  <p>Now problem is i need to save unique generated numbers into array (rejecting the generated duplicate number) and has to maintain order of generated numbers , without using any extra space and in <code>O(N)</code> complexity. i.e i same array i need to maintain order of generated number also. So that i can retrieve them in generated order. No bitmap or extra array etc is suppose to use.</p>
  
  <p>Its not a homework. Its one of the interview question. I am not supposed to  use any extra space. He asked me to use the fact that <code>k</code> is smaller than <code>N</code> and you need to inculcate the behavior of hashmap in same array. I proposed many algorithms using extra spaces but he rejected also using sorting , but i was not able to maintain generated order.</p>