PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Jane Street

Optimal Stopping for Die Rolls That Bust on Perfect Squares

Last updated: Jul 2, 2026

Optimal Stopping for Die Rolls That Bust on Perfect Squares

Company: Jane Street

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You repeatedly roll a fair six-sided die and keep a running cumulative sum $S$ of all the values rolled so far (starting from $S = 0$ before the first roll). - After any roll, you may choose to **stop** and walk away with a payoff equal to the current sum $S$. - However, if at any point the cumulative sum $S$ lands exactly on a positive perfect square ($1, 4, 9, 16, 25, \dots$), you immediately **lose everything**: the game ends with payoff $0$. - If you keep rolling and have not busted, the game continues indefinitely — there is no limit on the number of rolls. Determine the optimal strategy: for which values of the running sum should you keep rolling, and at which values should you stop and take the money? Justify why the strategy is optimal, and compute the expected payoff of the game under optimal play, starting from a sum of $0$.

Related Interview Questions

  • Collapsible Code Editor: Brace Matching and Toggle - Jane Street (medium)
  • Implement a Circular Buffer - Jane Street (medium)
  • Code Editor with Block Shrink and Expand (Code Folding) - Jane Street (medium)
  • Optimize trade PnL table updates - Jane Street (hard)
  • Transform sparse time-code stream to dense rows - Jane Street (easy)
|Home/Coding & Algorithms/Jane Street

Optimal Stopping for Die Rolls That Bust on Perfect Squares

Jane Street logo
Jane Street
Aug 3, 2025, 12:00 AM
mediumData ScientistOnsiteCoding & Algorithms
0
0

You repeatedly roll a fair six-sided die and keep a running cumulative sum SSS of all the values rolled so far (starting from S=0S = 0S=0 before the first roll).

  • After any roll, you may choose to stop and walk away with a payoff equal to the current sum SSS .
  • However, if at any point the cumulative sum SSS lands exactly on a positive perfect square ( 1,4,9,16,25,…1, 4, 9, 16, 25, \dots1,4,9,16,25,… ), you immediately lose everything : the game ends with payoff 000 .
  • If you keep rolling and have not busted, the game continues indefinitely — there is no limit on the number of rolls.

Determine the optimal strategy: for which values of the running sum should you keep rolling, and at which values should you stop and take the money? Justify why the strategy is optimal, and compute the expected payoff of the game under optimal play, starting from a sum of 000.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Jane Street•More Data Scientist•Jane Street Data Scientist•Jane Street Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.