Question
Compute how many retries a client-side retry budget permits. Maintain a token balance starting at min_budget. Process an ordered list of events: a 'req' event adds 'ratio' tokens to the balance (ratio is the retries-per-request allowance, e.g. 0.2); a 'retry' event is allowed only if the balance is >= 1.0, in which case it consumes 1.0 token and counts as allowed, otherwise it is denied (balance unchanged). Return the total number of retries that were allowed. ratio is a non-negative float; min_budget is a non-negative int.
retry_budget(requests: list[str], ratio: float, min_per_sec: int) → int[["req","req","req","req","req","retry","retry"],0.2,0]out1State 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.