title: Given an array of integers, find the first missing positive integer in linear time and constant space
body: <p>In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.
  This question was asked by Stripe in it's programming interview. I have devised a solution for the same as below:</p>
  
  <pre><code>#include&lt;bits/stdc++.h&gt;
  using namespace std;
  
  int main(){
      int arr[]={1,-1,-5,-3,3,4,2,8};
      int size= sizeof(arr)/sizeof(arr[0]);
      sort(arr, arr+size);
      int min=1;
  
      for(int i=0; i&lt;size; i++){
          if(arr[i]&gt;min) break;
          if(arr[i]==min) min=min+1;
      }
      cout&lt;&lt;min;
      return 0;
  }
  </code></pre>
  
  <p>Here, I am first sorting the array, and then traversing the array once. Before traversing the array, I have initialized a variable named "min" as 1. Now, while traversing the array, when we get an integer that is equal to min, we simply increment the value of min. This ensures that the min variable hold the latest least positive integer that has not occurred yet. 
  Can you think of any better approach? Thanks in advance.</p>