As we know that Array.prototype.some() and Array.prototype.includes() has time complexity of o(n). Now I want to know that what if I will use include inside some method. The time complexity will be linear or quadratic?
JavaScript
x
4
1
function checkDublicate (arr1, arr2) {
2
return arr1.some(item => arr2.includes(item));
3
}
4
Advertisement
Answer
It’s O(mn), where m is arr1.length
and n is arr2.length
.