Alice starts with a score of 0. While her score is strictly less than k, she repeatedly draws a number uniformly at random from the integers in the range [1,maxPts] and adds it to her score. As soon as her score becomes greater than or equal to k, she stops drawing.
Return the probability that Alice’s final score is less than or equal to n.
Constraints:
Input: n = 10-int, k = 1-int, maxPts = 10-int
Output: 1.0-float
Explanation: Alice stops after one draw because k = 1. Her final score is uniformly in [1..10], which is always <= n (10), so the probability is 1.
Input: n = 21-int, k = 17-int, maxPts = 10-int
Output: 0.73278-float
Explanation: Alice draws until her score reaches at least 17. Using dynamic programming with a sliding window of the last maxPts probabilities (each state averages the previous maxPts states while the score is < k), the summed probability of ending in [k..n] = [17..21] is 0.73278.
Input: n = 5-int, k = 0-int, maxPts = 7-int
Output: 1.0-float
Explanation: Since k = 0, Alice stops immediately with score 0. Because 0 <= n, the probability that the final score is <= n is 1.
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem: