I am not able to remove TLE error from this. Here are the original constraints for the problem.
1≤Ai≤N for each valid i
the sum of N over all test cases does not exceed 2⋅10^5.
def happy(L): for i in range(1,len(L)-1): j=i+1 while j<len(L): if L[i]==L[j]: if str(i) in L and str(j) in L: return "Truly Happy" j=j+1 return "Poor Chef"
for i in range(x):
for i in list:
Sub-Task Task # Result
1 0 AC
Subtask Score: 27.00% Result - AC
2 1 AC
2 2 TLE
2 3 TLE
Subtask Score: 0.00% Result - TLE
Total Score = 27.00%
I have tried to think about other algorithms but cant find better than this. Maybe problem lies in the input part, which increases time.