Decode length with cap
Your task
A run-length-encoded string repeats blocks of the form <count><char>, where <count> is a positive decimal integer of one or more digits and <char> is a single lowercase letter (e.g. "3a2b1c" decodes to "aaabbc", length 6). Given the encoded string s and an integer cap, return the decoded length, but as soon as the running decoded length would exceed cap, stop and return -1. The empty string decodes to length 0. Counts can be large, so you must not materialize the decoded string.
Examples
run_length_decode_capacity(s: str, cap: int) -> intExample 1
Input
run_length_decode_capacity("3a2b1c", 100)Output
6