FastPrepProbability of Reaching a Target Interval by Dice Rolls
Problems/Probability of Reaching a Target Interval by Dice Rolls

Probability of Reaching a Target Interval by Dice Rolls

Google logoGoogle● HardNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report states a one-dimensional start at zero, uniform rolls from 1 through K, an inclusive winning interval, and the probability to find. It describes a dynamic program using the law of total probability. We chose the function signature, how the end is worded, examples, finite limits, and a number tolerance. Our version is about 95% the same as the reported question.

You start at position 0 on an infinite one-dimensional grid. On every turn, independently choose a uniformly random integer from 1 through k and move that many positions to the right.

You win as soon as you land at any position in the inclusive interval [minTarget, maxTarget]. You lose if you move past maxTarget before landing in the interval.

Return the probability of winning. Answers within 1e-9 of the exact probability are accepted.

Function

reachIntervalProbability(k: int, minTarget: int, maxTarget: int) → double

Examples

Example 1

k = 2minTarget = 2maxTarget = 2return = 0.75

Rolling 2 wins immediately. After rolling 1, the next roll must be 1. The probability is 1/2 + (1/2)(1/2) = 3/4.

Example 2

k = 6minTarget = 1maxTarget = 1return = 0.16666666666666666

Only a first roll of 1 lands on the one-position target; every larger roll immediately passes it.

Example 3

k = 3minTarget = 2maxTarget = 3return = 0.8888888888888889

A first roll of 2 or 3 wins. After a first roll of 1, rolling 1 or 2 wins and rolling 3 loses.

Constraints

  • 1 <= k <= 200000.
  • 1 <= minTarget <= maxTarget <= 200000.
  • Every roll is independent and every value from 1 through k is equally likely.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • New 21 Game ProbabilityUiPath · PHONE SCREEN
  • Tree Path GCDNewton School · PHONE SCREEN
  • Count Stepping Numbers In RangeAmazon · PHONE SCREEN
  • Election District Budget Allocation AnalysisIMC Trading · PHONE SCREENIMC Trading interview questions
  • Maximum Visible DronesAnduril · PHONE SCREENAnduril interview questions
  • Count Clean Attendance LogsRippling · PHONE SCREENRippling interview questions
  • Sliding Window Attention over a KV CacheNVIDIA · PHONE SCREENNVIDIA interview questions
  • Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Dice Sum That Is a Multiple of mSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public double reachIntervalProbability(int k, int minTarget, int maxTarget) {
        // write your code here
    }
}
Checking account…