Solution in c++ using array


#1

int Solution::firstMissingPositive(vector &A)
{
int n=A.size();
int ar[n+1]={0};
int x;
for(x=0;x<n;x++)
{
if(A[x]>0 && A[x]<=n+1)
ar[A[x]-1]++;
}

for(x=0;x<n+1;x++)
{
   if(ar[x]==0)
        return x+1;
}
return x+1;

}