Find the intersection of two sets $A = \\{a0, a1, ..., a{n-1}\\}$ and $B = \\{b0, b1,…
- User
Find the intersection of two sets and .
Assistant
pythonimport sys n = int(sys.stdin.readline()) a = list(map(int, sys.stdin.readline().split())) m = int(sys.stdin.readline()) b = list(map(int, sys.stdin.readline().split())) i = j = 0 res = [] while i < n and j < m: if a[i] == b[j]: res.append(a[i]) i += 1 j += 1 elif a[i] < b[j]: i += 1 else: j += 1 for num in res: print(num)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.