Intersection of unsorted arrays
2022年5月1日小于 1 分钟
Intersection of unsorted arrays
Question
Given two arrays, find the intersection(items occur in both arrays)
- arrays are not sorted, and might have duplicates.
- you can modify the arrays
- you can return the items in any order, but without duplicates.
This is an easy problem, What is the time & space complexity of your approach?
Code
/**
* @param {any[]} arr1
* @param {any[]} arr2
* @returns {any[]}
*/
function getIntersection(arr1, arr2) {
// your code here
}