InterviewLegend

Sorting and Greedy Scans

Alex Chen38 min readUpdated 250 real interview reports

Sorting problems at D. E. Shaw rarely say they're about sorting. The prompt is a story with a list in it, and if you put that list in order, one pass usually gives the answer. Without the sort, the obvious code checks every pair or every target, and the hidden tests are sized so that version times out.

Not every problem in this group starts with a sort. Two of the four below open with one. The other two need a different scan instead, like reading the input from last to first, or filing each interval under its left end before you sweep.

In the live rounds, the interviewer usually accepts the slow version first. Then they ask what sorting buys you and what the new bound looks like. Have that answer ready before you write a line. Say the slow version's cost out loud, then name the sort or the scan direction that fixes it, and check equal values and large totals before you call it done.

D. E. ShawPremium lesson · Coding round

The 4 D. E. Shaw problems are below.

  1. A Premium questionCoding · Medium
  2. A Premium questionCoding · Medium
  3. A Premium questionCoding · Medium

+ 1 more in this lesson

Each with hints, the follow-up and a tested solution.

Get the D. E. Shaw questions

$49 a year · all 100 companies · cancel anytime

From 250 D. E. Shaw reports, forum threads behind logins and write-ups in Chinese.

Had your D. E. Shaw interview?Tell us what they asked. Reviewed before it goes in, never with your name.
D. E. Shaw interview guide

Know what D. E. Shaw asks before you walk in.

32 coding · 3 system design · 16 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.