```
public class Solution {
public int findPoisonedDuration(int[] timeSeries, int duration) {
// algorithm 2017/05/31: simply add up, each time we either add 'duration', or add the delta of time series, whichever smaller
if (null == timeSeries || 0 == timeSeries.length) {
return 0;
}
// kick start with the first attack
int result = duration;
for (int index = 1; index < timeSeries.length; index++) {
result += Math.min(duration, timeSeries[index] - timeSeries[index-1]);
}
return result;
}
}
```