← 返回 amazon 的题目列表Find Unique Common Elements of Two Lists Using Iterators
类型:online_judge
amazon
Given two lists, write a program to find their common elements. Optimize space complexity and use an iterator to implement.
Input
Two lines of input, each containing a space-separated list of integers.
Output
Output an integer list representing the intersection of the two input lists, ensuring each element is unique and sorting is not required.
Example
Input:
1 2 2 1
2 2
Output:
2
Input:
4 9 5
9 4 9 8 4
Output:
9 4
Constraints
Each list can contain up to 1000 integers, and each integer ranges from 0 to 10^5.
Example
Input
1 2 2 1
2 2