Trains the technique from
LeetCode 349Intersection of Two ArraysThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Two handheld scanners ran along the same loading dock for a shift. Their logs arrive as the integer arrays nums1 and nums2, where every entry is the bay code of one scan. A scanner may well have hit the same bay several times, so a code can repeat inside a log.
Collect the bay codes that turn up in both logs. Each such code belongs in the answer once, however many times it was scanned, and the answer may come back in whatever arrangement you find convenient. When the two scanners never touched a common bay, the answer is empty.
Example 1
Bays 7 and 12 appear on both logs; the repeats of 7 collapse into a single entry.
Example 2
Bay code 0 is a real code, so it counts just like any other shared bay.
Example 3
The two scanners covered disjoint stretches of the dock, so nothing is shared.
The values you return may be in any order.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def intersection(nums1: list[int], nums2: list[int]) -> list[int]:public int[] intersection(int[] nums1, int[] nums2)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.