InterviewLegend

Counting Subarrays and Numbers

Alex Chen38 min readUpdated 250 real interview reports

Some D. E. Shaw problems ask only for a number, like a count of subarrays or substrings. The brute force lists every candidate and counts it, and the test sizes are chosen so that listing them times out.

The fast versions count in blocks. You fix one end and work out how many partners it has in a single step, or you fix a length and solve for the start with a line of algebra. One of the problems below turns into plain bit counting once you play it in reverse.

Write the brute force for each one anyway. You won't submit it, but it checks your fast count on small inputs, and these counts slip by one easily. Also settle the definition before you count anything. Two of these problems come in versions that disagree, one on whether equal neighbors still count as sorted and the other on which substrings get counted, so work the sample by hand first.

D. E. ShawPremium lesson · Coding round

The 4 D. E. Shaw problems are below.

  1. A Premium questionCoding · Hard
  2. A Premium questionCoding · Hard
  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.