FastPrepEven and Odd Digit Pattern Probability
Problems/Even and Odd Digit Pattern Probability

Even and Odd Digit Pattern Probability

Jane Street logoJane Street● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in one Jane Street trading desk operations report from the U.K., posted in 2021. The process it describes includes a phone round of seven probability and maths questions; the report does not say which round its one listed question came from. That question is about how likely a random three-digit number is to have a given even and odd pattern in its first two digits.

Our function takes a pattern of up to nine digits, with a letter for even, a letter for odd and a wildcard. Picking every number of that length with equal chance, the pattern letters, the limit, the tolerance and the second and third examples are ours.

Our version is about 85% the same as the reported question.

Let n be the length of pattern. A whole number with exactly n digits is picked uniformly at random, so every number from 10n-1 to 10n - 1 is equally likely (for n = 1, the numbers 1 to 9). The first digit is never 0.

Character i of pattern describes digit i of the number, counting from the left:

  • 'E': the digit must be even (0, 2, 4, 6 or 8).
  • 'O': the digit must be odd.
  • '*': the digit can be anything.

Return the probability that the picked number fits the whole pattern. Answers within 10-6 of the correct value are accepted.

Function

digitParityProbability(pattern: String) → double

Examples

Example 1

pattern = "EO*"return = 0.2222222222222222

Three-digit numbers run from 100 to 999, so there are 900 of them. The first digit must be 2, 4, 6 or 8 (4 ways), the second must be odd (5 ways) and the third can be anything (10 ways). That is 4 * 5 * 10 = 200 numbers, and 200 / 900 = 2/9.

Example 2

pattern = "O"return = 0.5555555555555556

The one-digit numbers are 1 to 9. Five of them are odd, so the answer is 5/9. It is not 1/2, because 0 is not a choice for the first digit.

Example 3

pattern = "**E*"return = 0.5

Only the third digit is fixed, and it can be any of 0 to 9, half of them even. The answer is 1/2.

Constraints

  • 1 <= pattern.length <= 9
  • pattern contains only the characters 'E', 'O' and '*'.

More Jane Street Phone Screen questions

  • Maximum-Scoring Consecutive Tree LevelsPHONE SCREEN · Seen Nov 2026
  • Tree Selection and VisibilityPHONE SCREEN · Seen Nov 2026
  • Load/Store Arithmetic InterpreterPHONE SCREEN · Seen Oct 2026
  • Instrument Stack Language JumpsPHONE SCREEN · Seen Oct 2026
  • Run a Stack Language InterpreterPHONE SCREEN · Seen Oct 2026
  • Positive-Integer Expression EvaluationPHONE SCREEN · Seen Oct 2026
  • Add Two Integers Given as StringsPHONE SCREEN · Seen Sep 2026
  • Angle Between Clock HandsPHONE SCREEN · Seen Jul 2026
  • Route Length From Two CyclistsPHONE SCREEN · Seen Jul 2026
  • Sort TradesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026

Similar questions at other companies

  • Good SubsequencesNutanix · OANutanix interview questions
  • Unique Digit Permutations Without Leading ZeroMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
  • Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
  • Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
  • Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Revolver: Will the Next Shot Fire?Tower Research Capital · PHONE SCREEN
  • Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Expected Fake-Name CollisionsMercor · PHONE SCREENMercor interview questions

Interview reports that mention this question

  • Jane Street TDO UK and Hong Kong: 22 Experiences (Part 10 of 10)

Jane Street interview experiences

  • Jane Street TDOE US Final Round: 11 Experiences (Part 5 of 10)
  • Jane Street TDO Phone Math Round: 26 Experiences (Part 9 of 10)
  • Jane Street TDOE UK Phone Screen: 15 Experiences (Part 4 of 10)
  • Jane Street TDO Excel and VBA Test: 23 Experiences (Part 8 of 10)
  • Jane Street TDOE UK Coding Round: 15 Experiences (Part 3 of 10)
All Jane Street interview questionsSee Jane Street hiring insights
Saved
class Solution {
    public double digitParityProbability(String pattern) {
      // Write your code here.
    }
}
Checking account…