# Intersection of Two Arrays - Space Time And Complexity [closed]

The problem is as follows: Given two arrays, write a function to compute their intersection.

The below code is my solution.I'm just curious as to what the space time and complexity of below algorithm would be.

var intersection = function(nums1, nums2) {
const intersectionArr =  nums1.filter((value)=> nums2.includes(value));
return [...new Set(intersectionArr)];
};

• Please add tag of the language in which this is written (I suppose js?) Despite i think question purely about complexity iss offtopic on this site, the time complexity Is probably O(n^2) And Space Is O(n). – slepic Dec 25 '19 at 9:03