Intersection of Two Arrays

Easy

Given two integer arrays, return their intersection.

Every element in the result must be unique; the order does not matter.

Example 1

intersection()
Input
nums1 = [1,2,2,1], nums2 = [2,2]
Output
[2]

Example 2

intersection()
Input
nums1 = [4,9,5], nums2 = [9,4,9,8,4]
Output
[4,9]
Constraints
1 <= nums1.length, nums2.length <= 1000
0 <= nums1[i], nums2[i] <= 1000

Topics

ArraysHash Table

Implement intersection in the editor and return the answer — printing it is never graded.