Intersection of Two Arrays
Easy
Arrays
Array
Hash Table
Sorting
Given two arrays, return their intersection (unique common elements, any order, space-separated).
Constraints
1 ≤ length ≤ 1000
Examples
Example 1:
Input: 1 2 2 1
2 2
Output: 2
Example 2:
Input: 4 9 5
9 4 9 8 4
Output: 4 9
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console