N log n solution


#1

from collections import Counter
class Solution:
# @param A : list of integers
# @return an integer
def solve(self, A):
m=Counter(A)
n=len(A)
A.sort()
for i in range(n):
fwd=n-i-m[A[i]]
if fwd==A[i]:
return 1
m[A[i]]-=1
return -1