I get TLE with the following solution on codechef, I loop through only once keep two lists and find the majority
can someone help me to understand what should I do to not exceed the time limit?
l1, l2, l3 = tuple(map(int, input().split()))final = []interm = []i = 0while i< l1+l2+l3:id_num = input().strip()if id_num not in interm:interm.append(id_num)elif id_num in interm and id_num not in final:final.append(id_num)i+=1final.sort()print(len(final))print('\n'.join(final))
Read more… (37 words)