class Solution {

public:

int findPoisonedDuration(vector<int>& timeSeries, int duration) {

int size = timeSeries.size();

if(size==0) return 0;

int dur = 0;

int res =0;

for(int i =1;i<size; i++){

dur = timeSeries[i]-timeSeries[i-1];

res+=min(duration,dur);

}

return res+duration;

```
}
```

};