Code RoomExponential backoff with jitter
MediumPrep Room Coding #313

Exponential backoff with jitter

CodingNetworking & APIsMid–Senior~20 min

Compute a deterministic exponential-backoff-with-jitter schedule for a retry client. For attempt k (0-indexed) the uncapped delay is base*2**k, capped at cap, giving exp = min(cap, base*2**k). Jitter is full-jitter in [0, exp] derived from a deterministic LCG: starting from the given integer seed, before each attempt update state = (1103515245*state + 12345) % 2147483648, then the jittered delay is state % (exp + 1). Return the list of jittered delays for attempts 0..attempts-1. base, cap, seed are positive ints; attempts >= 0.

Implement
backoff_schedule(base: int, cap: int, attempts: int, seed: int) → list[int]
Examples
in[100,1000,3,42]out[79,122,100]
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 20 min
InputExpectedGot
[100,1000,3,42][79,122,100]not run yetsample