> class Solution:
> # @param A : list of integers
> # @return an integer
> def solve(self, A):
> A.sort()
> j=0
> #print(A)
> while j<len(A):
> if A[j]>=0:
> if A[j]==0 and j==len(A)-1:
> return 1
> elif A[j]==len(A[j+1:]) and A[j]!=A[j+1]:
> return 1
> j+=1
> return -1
Why is this exceeding the time limit?
crazyJuice
#1
abhishekwl
#2
A.sort() in on itself has a time complexity of O(n), that’s probably why it’s exceeding the time limit