```
public int findPoisonedDuration(int[] timeSeries, int duration) {
if (timeSeries == null || timeSeries.length == 0) {
return 0;
}
int result = duration;
for (int i = 1; i < timeSeries.length; i++) {
result += Math.min(timeSeries[i] - timeSeries[i - 1], duration);
}
return result;
}
```

and python

```
def findPoisonedDuration(self, timeSeries, duration):
"""
:type timeSeries: List[int]
:type duration: int
:rtype: int
"""
if not timeSeries:
return 0
result = duration
for i in range(len(timeSeries) - 1):
result += min(timeSeries[i + 1] - timeSeries[i], duration)
return result
```