4. Fix the retry policy
MediumDebugging & productionDebugging
callWithRetry(statuses, maxAttempts) simulates calling a flaky API: statuses[i] is the HTTP status returned by attempt i + 1. Return { status, attempts, delays }.
Rules: retry only on 429, 500, 502, 503 or 504; never exceed maxAttempts total attempts; wait 100 ms before the first retry and double the wait each time (capped at 1000 ms). delays lists the waits used. The current code hammers the API and retries client errors.
Example 1
Input: callWithRetry([503, 503, 200], 3)
Output: { status: 200, attempts: 3, delays: [100, 200] }Constraints
Fix the bug; keep the function signature