CapitalIQ Interview Question for Consultants


Country: India
Interview Type: Phone Interview




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

You can do this in linear time, O(n), using hashset.

1. Add all the elements of one array into hashset.
2. loop over the elements of second array and check if it is present in hashset. If it is then add it to the result array.

- Anonymous June 19, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

The result array should also be a hashset to prevent duplicates in the output.

- dgw47@cornell.edu October 01, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

we can do this with O(nlogn) complexity...by using binary search tree..
1.sort any one array.
2.From the second array take one one element and do binary search tree in the sorted array ..if element is present insert that element in binary search tree..
3. if the element is already present just increment the count at that node..
4.after all the elements in the second array traverse the binary search tree and display the elements only whose count value is 1..
it takes O(nlogn).

if the arrays the same in size
sorting=O(nlogn)
searching=O(nlogn)
for BST O(nlogn)..
else
small change but ~==O(nlogn)..

- Anonymous June 19, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Sort both Arrays. O(nlogn). If space is not an issue, use O(n) Sorting (Counting/Radix)

Perform a merge operation O(n), only print those numbers present in both arrays.

Overall complexity O(nlogn) (or O(n))

- gaurav.kamath108 June 20, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

None of the above are accurate solutions

- Anonymous June 25, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ss

- shivanand217 August 24, 2017 | 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