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?
function checkDublicate (arr1, arr2) {
return arr1.some(item => arr2.includes(item));
}
Advertisement
Answer
It’s O(mn), where m is arr1.length and n is arr2.length.