What is wrong in my python code?

def solve(self, A):
    if A[0]==0:
        return -1
    for i in range(len(A)):
        for j in range(len(A)):
            if (A[j] > A[i]):
                count += 1
        if (count == A[i]):
            return 1
    return -1


Your first condition is wrong… if in the reverse sorted list first element is zero… then there are zero elements greater than zero… and so our condition becomes true… so you should return 1,
plus you could optimize your code further… like in sorted list the position of the i’th element itself tells you number of elements greater than it… so you need not count it…