I was trying to solve the above problem, but on submitting I am getting Time Limit Exceed error. I have tried test cases, and its giving me the desired output. But, on submitting facing this Time Limit issue.
Can someone please help me out.
This is the code which I wrote -:
T = int(input()) for k in range(0,T): N = int(input()) alpha =  for j in range(0,N): word,boolean = input().split() boolean = int(boolean) if len(alpha) == 0: alpha.append([word,boolean]) else: for i in alpha: if i == word and i == boolean: alpha.append([word,boolean]) break elif i == word and i !=boolean: continue else: alpha.append([word,boolean]) break print(len(alpha)) except: pass
This is the link for my solution
Thanks in advance.