Original
/**
* @param {number[]} timeSeries
* @param {number} duration
* @return {number}
*/
var findPoisonedDuration = function(timeSeries, duration) {
let total = 0;
let len = timeSeries.length;
if(!len){
return 0;
}
for(let i = 0; i < len - 1; ++i){
total += (timeSeries[i] + duration < timeSeries[i + 1] ? duration : timeSeries[i + 1] - timeSeries[i]);
}
total += duration;
return total;
};
複製程式碼