Deshaw Inc Interview Question for Software Engineer / Developers






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

In java, I think you can add the array elements to a Set (this data structure does not allow duplicates) and print the contents of the array

I'm completely new to data structures, correct me if I'm wrong.

- Ashok August 08, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

In java, I think you can add the array elements to a Set (this data structure does not allow duplicates) and print the contents of the array

I'm completely new to data structures, correct me if I'm wrong.

- Ashok August 08, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This can't be done in linear time if the array has numbers in random order. It has been proven the uniqueness/duplicacy finding is nlogn time in the worst case.
It array is sorted then a linear solution is pretty easy.

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

If we know the range of numbers existing in this array (lets say m to n) then we can have an Hash Table with indexes m to n with all items set to zero(0) to start off with. Now, run through the given array and set the corresponding items to true (1) in the hash table. If the value in hash table already = 1 then don't print that item in the array and move ahead. This way we we can print the array elements skipping the duplicates in linear time.

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

time complexity cannot be linear in worst case without increasing the memory requirements.... otherwise the soln by Nils is appropriate....

- lk July 25, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hi,

You can use Radix sort. Assuming integers, you can say that the memory consumption is 0(1) in the sense it doesnt depend upon the input N (which is the size of the array). After having done that, you can find the duplicates in O(n).

Thanks,
Rohith Menon.

- Rohith Menon August 20, 2008 | 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