Pergunta de entrevista da empresa GoFundMe

Find the intersection of two arrays.

Respostas da entrevista

Sigiloso

6 de ago. de 2019

Used two hashmaps to keep the count. And then iterate the hashmaps again. Time complexity was O(mn).

Sigiloso

30 de set. de 2019

^^ I did the same thing, i don't think the time complexity is O(mn), it is O(m + n) which ever list is bigger. this is because you have one loop to iterate though one list and store it in the hashmap which is m time. We do another hashmap iterating through the next list also checking the hashmap, but this is n time. since these are two separate iterations, it is m+n time.