title: Longest Consecutive Sequence in an Unsorted Array
body: <p>You are given an Array of numbers and they are unsorted/random order. You are supposed to find the longest sequence of consecutive numbers in the array. Note the sequence need not be in sorted order within the array. Here is an example :  </p>
  
  <p>Input :  </p>
  
  <pre><code>A[] = {10,21,45,22,7,2,67,19,13,45,12,11,18,16,17,100,201,20,101}  
  </code></pre>
  
  <p>Output is :  </p>
  
  <pre><code>{16,17,18,19,20,21,22}  
  </code></pre>
  
  <p>The solution needs to be of O(n) complexity. </p>
  
  <p>I am told that the solution involves using a hash table and I did come across few implementations that used 2 hash tables. One cannot sort and solve this because sorting would take O(nlgn) which is not what is desired.</p>