fast-doctor-62382
10/05/2020, 4:29 AMfunction containCommonItems(firstArray, secondArray) {
return firstArray.some(item => secondArray.includes(item))
}
I'm not exactly sure what happens inside the include method. So I'm assuming It's a loop, and the time complexity of the above function is O(n * m). But I have heard some other guys saying it O(n+m).
Could someone clarify this.?wonderful-dusk-20983
10/05/2020, 4:32 AMsome
method for Arrayswonderful-dusk-20983
10/05/2020, 4:34 AMfast-doctor-62382
10/05/2020, 4:48 AMdazzling-autumn-14365
10/05/2020, 4:53 AMincludes
) uses linear search. https://tc39.es/ecma262/#sec-array.prototype.includesfast-doctor-62382
10/05/2020, 6:13 AMdazzling-autumn-14365
10/05/2020, 6:24 AMfast-doctor-62382
10/05/2020, 6:57 AM