Tuesday 6 June 2017

Calculating the cumulative ttl (Time to live) for a series of requests

I have a series of requests and asked to calculate a the cumulative ttl of the series and given these requests .

let requests = [
{requestId: 'poiax',  startedAt: 1489744808, ttl: 8},
{requestId: 'kdfhd',  startedAt: 1489744803, ttl: 3},
{requestId: 'uqwyet', startedAt: 1489744806, ttl: 12}, 
{requestId: 'qewaz',  startedAt: 1489744810, ttl: 1}
]

What is the algorithm to solve this as I know that the answer should be 15 in the end.

I would assume that the earliest request 1489744803 should have the largest ttl but thats not the case, instead the 1489744806 request has the largest here so why is it like that?

Thanks :D



via stringRay2014

No comments:

Post a Comment