Easy solution, time : nlogn space : contsant

interview-questions
programming
Tags: #<Tag:0x00007f182827f870> #<Tag:0x00007f182827f2d0>

#1

int n = A.size();
sort(A.begin(),A.end());

for(int i=n-2;i>=0;i--)
        if(A[i] != A[i+1] && A[i] == n-1-i)
            return 1;
return A[n-1]==0 ? 1 : -1;