4 lines O(n) Python
\nclass Solution(object):\n    def findPosisonedDuration(self, timeSeries, duration):\n        """\n        :type timeSeries: List[int]\n        :type duration:
```\nclass Solution(object):\n    def findPosisonedDuration(self, timeSeries, duration):\n        """\n        :type timeSeries: List[int]\n        :type duration: int\n        :rtype: int\n        """\n        ans = 0\n        for i in range(len(timeSeries) - 1):\n            ans += min(duration, timeSeries[i+1] - timeSeries[i])\n        return ans + duration if timeSeries else 0\n```
[]