C++ solution easy to understand


  • 0
    A

    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;

    }
    

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.