Code Room
CodingHardcod-g277
Subject Probability dpLevel Senior–Staff~40 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

You start with 0 points. While your score is strictly less than 'stop', you draw a number uniformly from 1..maxPts and add it. You stop drawing once your score is >= stop. Return the probability that your final score is <= target, rounded to 6 decimals. 0 <= stop <= 1000, 1 <= maxPts <= 1000, 0 <= target <= 1000 (target may exceed stop). If stop==0 you draw nothing and final score is 0.

Implement
prob_at_most(stop: int, target: int, maxPts: int) → float
Examples
in[10,12,6]out0.728183
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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.