| 6 | //similar to overlapping subintervals problems |
| 7 | |
| 8 | class Solution { |
| 9 | public: |
| 10 | int findPoisonedDuration(vector<int>& timeSeries, int duration) { |
| 11 | |
| 12 | int n = timeSeries.size(); |
| 13 | if(n==0) |
| 14 | return 0; |
| 15 | |
| 16 | int ans = duration; |
| 17 | |
| 18 | for(int i=0; i<n-1; i++) |
| 19 | { |
| 20 | ans += duration; |
| 21 | if(timeSeries[i+1] < timeSeries[i] + duration) //overlapping condition |
| 22 | { |
| 23 | ans -= (timeSeries[i] + duration - timeSeries[i+1]); //the overlapped time subtracted |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | return ans; |
| 28 | } |
| 29 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected