GoFundMe Interview Question

Find the intersection of two arrays.

Interview Answers

Anonymous

Aug 6, 2019

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

Anonymous

Sep 30, 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.