题解 | #打印两个升序链表的公共部分#
打印两个升序链表的公共部分
http://www.nowcoder.com/practice/8943eea40dbb4185b187d80fd050fee9
n = int(input())
l1 = list(map(int, input().split()))
m = int(input())
l2 = list(map(int, input().split()))
res = []
i, j = 0, 0
while i < n and j < m:
if l1[i] == l2[j]:
res.append(l1[i])
i += 1
j += 1
elif l1[i] > l2[j]:
j += 1
else:
i += 1
print(*res)