[leetcode]495. Teemo Attacking
Analysis
new plan~—— [好好养生啊!!]
In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo’s attacking ascending time series towards Ashe and the poisoning time duration per Teemo’s attacking, you need to output the total time that Ashe is in poisoned condition.
You may assume that Teemo attacks at the very beginning of a specific time point, and makes Ashe be in poisoned condition immediately.
题目很简单啦~但是很搞笑啊,想想很久没玩lol了,哈哈哈(团战可以输,提莫必须死!!)
Implement
class Solution {
public:
int findPoisonedDuration(vector<int>& timeSeries, int duration) {
int len = timeSeries.size();
if(len == 0)
return 0;
int res = 0;
for(int i=0; i<len-1; i++){
if(timeSeries[i]+duration <= timeSeries[i+1])
res += duration;
else
res += (timeSeries[i+1]-timeSeries[i]);
}
res += duration;
return res;
}
};