First Missing Integer in Java solution


#1
       int n=A.size();
       Collections.sort(A);
       int[] arr=new int[n+1];
       arr[0]=0;
       for(int i=0;i<n;i++)
       {
            if(A.get(i) >=1 && A.get(i)<=n)
            arr[A.get(i)]++;
       }
       for(int i=1;i<=n;i++)
       {
           if(arr[i]==0)
           return i;
       }
       return n+1;

#2

you cannot use Collections.sort -> it changes time complexity to nlogn