Help me with array of negative integers


#1

I am not able to understand how the problem is solved for negative integers?can anyone help me via dry running one test case.
for eg: A : [ -1, -2, 0, 0, 0, -3 ]


#2

if you sort the array u would likely get [-3,-2,-1,0,0,0]. since the last element is 0 and also the number of integers greater than that is also 0, the expected answer to be returned is 1.


#3

A.sort()
if A[len(A)-1]==0:
return 1
for i in range(len(A)-1):
if A[i]!=A[i+1]:
if A[i]==len(A)-i-1:
return 1
return -1