Given two integer arrays nums1 and nums2, find their intersection.
Example 1:
nums1: [1, 2, 3, 4]
nums2: [1, 2]
result: [1, 2]
This problem asks for the intersection of two integer arrays. A common approach is to store the elements of one array in a hash set, then scan the other array and collect values that also appear in the set. For the example [1, 2, 3, 4] and [1, 2], the intersection is [1, 2]. If duplicates should be removed, a set-based solution is especially natural; if order matters, the traversal logic should preserve it.