Can anyone tell me what is wrong in my python code?

question:https://www.codechef.com/problems/CHEFDETE
my code:https://www.codechef.com/viewsolution/25252520

Because of if i not in a: in line 6, the complexity is O(n^2) that’s why you get TLE in second subtask.

Wouldn’t it be great if you could make an boolean array which would be true if i was in the array and false otherwise? :thinking:

1 Like

can you please give me any example for which my code gives wrong output

It does not give wrong output for any input. It’s just that it will take > 1 sec for inputs greater than 10^5 in length. One such example is:

100000
0 1 2 3 4 ... 99999
1 Like