Leetcode 495 Solution
This article provides solution to leetcode question 495 (teemo-attacking)
Access this page by simply typing in "lcs 495" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/teemo-attacking
Solution
class Solution {
public:
int findPoisonedDuration(vector<int>& timeSeries, int duration) {
int64_t end = 0;
int64_t total = 0;
for (int i = 0; i < timeSeries.size(); i++)
{
total += (int64_t)timeSeries[i] + duration - max(end, (int64_t)timeSeries[i]);
end = (int64_t)timeSeries[i] + duration;
}
return total;
}
};