CapitalIQ Interview Question for Consultants


Country: India
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
2
of 4 vote

Since a hashset maintains uniqueness of elements, why not just add the elements from the array to a hashset, iterate over the hashset and print them? Time complexity: O(n).

- Murali Mohan June 19, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It was a correct note to use set instead of a map, since we only need to keep track of existing (encountered) values, but not a key-value pair.

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

Just sort the array and then start traversing the array and keep the traversed element in another array..if during traversing you get a condition where arr[i]==arr[i+1] then ignore this value otherwise keep copying the elements.It will time for sorting the array and then traversing which will take O(nlogn).

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

1. consider given array(arr ), other array (Oarr), and a hash Map (HMap<int,int>);
2. key of HMap is element of arr,
3. if ith element of arr has count>0 in HMap, ignore it otherwise store in Oarr.

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

O(n) time complexity.

- Zzenith June 19, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Your steps would miss repeated elements and the in the new array you will have only the unique elements. The purpose is not met.

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

map mymap;
int givenarr[n];
int otherarr[n];
j = 0
for i = 0 to n - 1
	if not mymap.containskey(givenarr[i])
		otherarr[j++] = givenarr[i]
		mymap[givenarr[i]] = something
while j < n
	otherarr[j++] = Nothing

O(nlogn)

- coding.arya June 19, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@coding.arya
Complexities should be as follows
Space: O(m), where m is the number of unique elements from the given input of n
Time: O(n)

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

1. sort the array in ascending order( O(log n) )
2. and simply copy element from given array to another array and keep record of last copied in element in variable. continue this process till the end of array. (O(n))
so total time complexity O(n).

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

@Ganesh
Sorting takes O(n log n).

- arun_lisieux June 19, 2013 | Flag


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