Math Fundamentals18 sections · 814 units
Open in Course

Problem - Intersection of Two Arrays

LeetCode 349

Given two arrays nums1\text{nums1} and nums2\text{nums2}, return an array of their intersection. Each element in the result must be unique and you can return the result in any order.

For example, if nums1=[1,2,2,1]\text{nums1} = [1, 2, 2, 1] and nums2=[2,2]\text{nums2} = [2, 2], the answer is [2][2].

This is a direct application of set intersection. Before reading the solution, think about how you would find common elements between two collections.