Leetcode 495. Teemo Attacking

關關的刷題日記發表於2018-02-23
class Solution {
public:
    int findPoisonedDuration(vector<int>& timeSeries, int duration) {
        int re=duration;
        for(int i=1; i<timeSeries.size(); ++i)
        {
            re+= timeSeries[i]-timeSeries[i-1]>= duration ? duration :timeSeries[i]-timeSeries[i-1];
        }
        return timeSeries.empty()?0:re;
    }
};

相關文章