EFI Interview Question for Software Engineer / Developers






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

you could use a hash table to find common elements in o(n).

- jerry April 03, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You could qualify your answer by saying Hash table vs Array depending on target platform and hardware. Both have O(1) lookup but vary in computational overhead. Hash table would be good for a device w/ little mem. Array is good for a device with a lot of mem.

- Jack April 03, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I believe the solution the interviewers expect is the algo. They are not interested in which collections object you will be using.

The soultion should be: (lets say the first array has m elements and the second array has n elements. And x are the repeatitions in the first array of m elements)

Step 1: to remove all the duplicates from the first array by a linear search. it will be m*m and crete a new set containing m-x elements.

Step 2: now again perform linear search for each element of m-x elements array on the second array. and break the loop when the identical value is found. So the time taken is (m-x) * logn

So total time taken = m*m + (m-x) * logn

If there is a optimised solution please let me know.

- ksk April 09, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In step 1, how can you remove those repetitions without looking at array 2. It is supposed to remove common elements.

- Kevin May 20, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You need to construct a Hash table of one of the arrays(I prefer the smaller one) . Then use to second array to hash into the table to see if they already exist. Solution is O(n).
Binary tree can be an answer but I would suggest an AVL tree rather than just a Binary tree as AVL is balanced and search is almost always lg n but this ofcourse involves additional operations for balancing.

- Krishh February 12, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

sort both arrays by quicksort.it will take 2O(nlogn) time to sort.
Now number to number match both arrays.for eg.
let after sorting
a=1,2,4,4,6,8
b=2,3,4,5,7
so now match like this..
1!=2 and 1<2
next element frm a
2=2 match
2!= 3 and 2<3
next element frm a.
here length of a and b can be compared to get better result.

- Jim January 24, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

simplest solution.. since no efficency thing is asked .. remove duplicates in one array & do linear search with the other array removing any duplicates

- Anonymous May 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

since there was no efficiency thing mentioned.....simply merge the two arrays and then add it to a hash set.

- alok November 30, 2015 | Flag Reply


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More