Prepping for the 2027 recruiting cycle? Use code 2027RC for 10% off, valid until July 31st! Oh, and check out our members-only recruitment services.

Logo

Coding preview

Fair Coin Run Length

What this preview is

About this preview

Fair Coin Run Length is a easy quant coding problem on probability in Python, asked at Quant.

Unlock full access to getcracked

Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.

Finding the longest consecutive run in a sequence

This easy coding problem tests your ability to scan through a sequence and track state—a pattern that appears frequently in market-data processing. Quant trading teams ask this kind of question to verify that you can write clean, correct code quickly, even under time pressure.

The core skill is recognizing when to reset a counter and when to accumulate it. You'll need to handle edge cases like empty input, sequences with no heads at all, and runs that extend to the end of the list. Most candidates solve this in a single linear pass without extra data structures.

  • Single-pass scanning and state tracking
  • Boundary and edge-case handling
  • Comparing and updating a running maximum