```
public class Solution {
/*
if time.length == 0: return 0
for i = 1...n
diff = time[i] - time[i-1]
result += diff > duration ? duration : diff
result += duration
*/
public int findPoisonedDuration(int[] timeSeries, int duration) {
if (timeSeries.length == 0) return 0;
int result = 0;
for (int i = 1; i < timeSeries.length; i += 1)
result += Math.min(timeSeries[i] - timeSeries[i-1], duration);
result += duration;
return result;
```

```
}
```

}