Code RoomNew 21 game
HardPrep Room Coding #1469

New 21 game

CodingAlgorithms & data structuresSenior–Staff~35 min

You start with 0 points and keep drawing while your score is strictly less than k. Each draw adds a uniformly random integer from 1 to maxPts (inclusive) to your score. You stop as soon as your score is >= k. Return the probability that your final score is <= n, rounded to 5 decimal places. 0 <= k <= n <= 10^4, 1 <= maxPts <= 10^4.

Implement
new21_game(n: int, k: int, maxPts: int) → float
Examples
in[10,1,10]out1
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 35 min
InputExpectedGot
[10,1,10]1not run yetsample