## Lab126 Interview Question for Software Engineer / Developers

Country: United States

Comment hidden because of low score. Click to expand.
1
of 1 vote

solution for two array list:-
- O(N^2) - brute force match between two array.
- O(nlogn) - sort both array in O(NlogN), then compare both the list, that will take O(N)
- O(N) - if array is not too big, then store contain of first array in hashmap, then iterate through the second array and check whether number is there in the hashmap or not.

for N integer array , take two array and use above solution, then create a new array with the intersection then use that with next array to find intersection.
repeat the steps till all array is covered.

Comment hidden because of low score. Click to expand.
0
of 0 vote

Keep a hashmap that keeps count of how many times we've seen an integer in an array. For simplicity assume no duplicates.

After a sweep through the N arrays, we have a hash map containing the number of occurrences for each integer. Return a list of integers that had an occurrence of N.

Finally fix the duplicate error. Every time you start scanning a new array you keep a hashset of values you've seen in that array so far. This way you know if you've hit a duplicate or not.

Time Complexity: O(N*M)
where N is the number of arrays and M is the size of the largest array given.
Space Complexity: O(N*M) if we have to store all of that into a hash map. O(K) actually where K is the size of the map we use.

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.