Pergunta de entrevista da empresa Atlassian

Find the intersecting values of 2 arrays.

Resposta da entrevista

Sigiloso

22 de fev. de 2019

I answered this immediately with the code below but I explained that it could be further optimized with a map to reduce complexity. We talked about Big O notation for a while then moved on to the next question. Problem: // arr1 = [1, 2, 5] and arr2 = [3, 2, 5, 6] // intersection: [2, 5] Solution: const arr1 = [1, 2, 5]; const arr2 = [3, 2, 5, 6]; console.log(arr1.filter(num => arr2.includes(num))) // outputs: [ 2, 5 ]