|
|
back to boardTLE #8: How can I make this Python code faster? import sys p = input() p_list = [] for i in range(int(p)): x = input() p_list.append(x) s = input() s_list = [] for i in range(int(s)): x = input() s_list.append(x) count = 0 l = set(s_list).intersection(p_list) for i in l: count += s_list.count(i)
print (count) Re: TLE #8: How can I make this Python code faster? import sys ll = set() for i in range(int(sys.stdin.readline())): ll.add(sys.stdin.readline()) n = 0 for j in range(int(sys.stdin.readline())): if sys.stdin.readline() in ll: n += 1 print(n) |
|
|