349. Intersection of Two Arrays

find intersection, use set, this one is better

time: O(n)

space: O(n)

sort first, then use binary search, find and add into set, this is another thought, but time complexity is not good.

time: O(nlogn)

space: O(n)

JS

Last updated

Was this helpful?