Leetcode 495 Teemo Attacking
来源:互联网 发布:淘宝新店怎么增加流量 编辑:程序博客网 时间:2024/06/05 14:24
In LLP 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.
class Solution {
public:int findPoisonedDuration(vector<int>& timeSeries, int duration) {
int total = 0;
if(timeSeries.size() == 0) {
return total;
}
else {
for(int i = 0; i < timeSeries.size(); i++) {
if(i != timeSeries.size()-1) {
if(timeSeries[i+1] - timeSeries[i] >= duration) {
total += duration;
}
else {
total += timeSeries[i+1] - timeSeries[i];
}
}
else total += duration;
}
}
return total;
}
};
1 0
- LeetCode 495 --- Teemo Attacking
- Leetcode 495 Teemo Attacking
- LeetCode 495 Teemo Attacking
- [Leetcode 495] Teemo Attacking
- LeetCode.495 Teemo Attacking
- leetcode 495 Teemo Attacking C++
- leetcode 495[medium]----Teemo Attacking
- LeetCode题解:Teemo Attacking
- LeetCode 495. Teemo Attacking
- LeetCode: Teemo Attacking
- LeetCode 495. Teemo Attacking
- LeetCode:495. Teemo Attacking
- 【Leetcode】495. Teemo Attacking
- [leetcode] 495. Teemo Attacking
- LeetCode|Array|Teemo Attacking
- leetcode 495. Teemo Attacking
- 【LeetCode】495. Teemo Attacking
- LeetCode 495. Teemo Attacking
- MyBatis获取插入记录的自增主键
- [LeetCode] Longest Palindromic Substring(java)
- Android四大组件——Service后台服务、前台服务、IntentService、跨进程服务、无障碍服务、系统服务
- Laravel变向运行指定的migration文件的方法
- 冒泡排序及其优化
- Leetcode 495 Teemo Attacking
- leetcode5. Longest Palindromic Substring
- [转] HTTPS详解SSL/TLS
- JavaWeb学习(二)
- windows 学习
- 猫哥带你去战斗—Java Web开发—Servlet篇[4]—JSP顺势而生
- 利用Python数据分析:pandas入门(五)
- MyBatis学习笔记(5)
- 位运算之两数相除