Problem statement
Write function solution(statuses, baseMs, maxMs). Inputs and outputs are JSON values. Do not modify input arrays or objects. External libraries, network access, and asynchronous functions are not supported. statuses:integer[] (100–599); baseMs,maxMs:integers 0–10^6. First attempt starts at 0. Append the time of each processed response. Stop after a 2xx success or a 4xx except 408/429. Otherwise add min(maxMs,baseMs*2^i) after response i, zero-based. Do not create attempts beyond the supplied responses. Return the attempt-time array. Input limits: at most 50,000 items per input array and 1,000 characters per string. Numbers are finite; integers and accumulated integer results stay in the JavaScript safe-integer range. Other types and validity rules follow the statement above.
Example input and output
Example 1
Function arguments
[
[
500,
500,
200
],
100,
1000
]Return value
[ 0, 100, 300 ]
Example 2
Function arguments
[
[
429,
408,
503,
200
],
10,
25
]Return value
[ 0, 10, 30, 55 ]
Example 3
Function arguments
[
[
401
],
1,
10
]Return value
[ 0 ]