Deshaw Inc Interview Question for Software Engineer / Developers






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

1) take a doubly circular linked list, take two pointers(forp and backp) and start from any point, calculate X(Ci-Gi).
2) when moving forward to next station using forp calculate sum = sum + X. if sum is -ve move back using backp and calculate sum = sum + (Ci-1 - Gi-1). continue to move back till sum becomes +ve and then start again moving forward using step 2 itself.
3) when forp equals backp and sum is +ve u have got the starting station else if sum is -ve there is no starting station.
This is a linear time algorithm.

- Lokendra Kumar Singh July 30, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

0. Able to complete one round => sum(Ci-Gi) >= 0
1. Start from any point, say, point 1,
2. Accumulate (Ci-Gi) from 1 to point k, Ak = sum(Ci-Gi) from 1 to k, for k = 1,..,n
3. The start point should be k = argmin(Ak), i.e., where Ak reach minimum.

In algorithm, remember the minimum and its index during accumulation, it's linear time.

- Bing November 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Ne 1 plz elabrote the above Algo..............given by LKS

- Kush June 10, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Bum. It is simple
1. Select any start point.
2. Move on unless you have enough gas
3. Select the last station you have succefully passed as a new start point. (There is no reason move back and force)
4. Goto 2

- Val July 07, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

0. Able to complete one round => sum(Ci-Gi) >= 0
1. Start from any point, say, point 1,
2. Accumulate (Ci-Gi) from 1 to point k, Ak = sum(Ci-Gi) from 1 to k, for k = 1,..,n
3. The start point should be k = argmin(Ak), i.e., where Ak reach minimum.

In algorithm, remember the minimum and its index during accumulation, it's linear time.

- Bing November 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

My idea is based on greedy algo: find a sequence of Ck, Ck+1, .... Ck+m that yields the largest sum. Ck will be the starting point.

AS you may already know, finding such sequence is O(n)

- Silence February 07, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

getting confused, isnt it travelling sales man problem which is NP-complete...:(

How are they expecting O(n) algo?

- Anonymous August 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

nopes..its not TSP.

- Anonymous August 24, 2010 | 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