A linear time solution using python

```
def findPoisonedDuration(self, timeSeries, duration):
"""
:type timeSeries: List[int]
:type duration: int
:rtype: int
"""
preTime, poisonTime = -1, -1
answer = 0
for newTime in timeSeries:
if newTime > poisonTime:
answer += duration
if newTime == poisonTime:
answer = answer + duration
if newTime < poisonTime:
answer = answer + (newTime - preTime)
poisonTime = newTime + duration
preTime = newTime
return answer
```