Deshaw Inc Interview Question for Software Engineer / Developers






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

Assign a value for marbles of each color.Sort them O(nlogn).
If the no of colors are 2 or 3 then we can do it in O(n)

- dream December 28, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

sry i am not clear with question pls give one input and output test case for this problem.

- DinakaranGCT December 31, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It resembles to concept of bucket sort as commented about assign a value to each color say red = 0.1 blue = 0.2 etc

let a[] be the array of marbles scattered (0.1,0.2,0.1,0.4,0.2....)
for(int i=0; i<n; i++)
insert a[i] into b[n*a[i]]
where n is total number of colors

insert in to b using a linklist

refer CLRS pg 174 Bucketsort

that does it in O(n) with space complexity n+ (total no of marbles)/n

- Shirish January 09, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is an example of Dutch National Flag problem.
Try Wikipedia search

- Krishna September 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

As per my interpretation, the boxes of the marbles are not labelled with any particular colour. As an example consider two boxes B1 and B2
B1 has 70 Green and 20 Red balls
B2 has 30 Green and 10 Red balls
Optimal way would be to put 30 Green from box B2 to B1 and 20 Red from B1 to B2.

- Nomad October 27, 2013 | 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