Week Training: 495 Teemo Attacking
来源:互联网 发布:湘潭大学网络 编辑:程序博客网 时间:2024/06/05 08:15
Although the difficulty of the problem is "medium", it's a easy problem obscured by a story. The fact of the problem is just to find the total length of effective insertion of a integer to a sequence. We just need to judge if the interval of the sequence is bigger or less than the integer, and decide what to add. In addition, judgement of whether the sequence is empty and the duration is zero is required.
class Solution {public: int findPoisonedDuration(vector<int>& timeSeries, int duration) { int sum = duration; if(timeSeries.empty()) return 0; for(int i=0; i<timeSeries.size()-1; i++){ if((timeSeries[i+1]-timeSeries[i])>=duration) sum += duration; else sum += (timeSeries[i + 1] - timeSeries[i]); } if(duration == 0) sum = 0; return sum; }};
0 0
- Week Training: 495 Teemo Attacking
- 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
- Teemo Attacking
- Teemo Attacking
- Teemo Attacking
- LeetCode题解:Teemo Attacking
- 495. Teemo Attacking
- LeetCode 495. Teemo Attacking
- LeetCode: Teemo Attacking
- LeetCode 495. Teemo Attacking
- 495. Teemo Attacking
- 495. Teemo Attacking
- Uva1606 Amphiphilic Carbon Molecules【例题8-6】【极角扫描法】【不懂!】
- ie6~9浏览器默认属性
- webservice 应用实例
- 深入理解Spark 2.1 Core (十一):Shuffle Reduce 端的原理与源码分析
- 【Unity&2.5D&Shader】2D2.5D精灵实时阴影怎么使用
- Week Training: 495 Teemo Attacking
- git对比svn有什么优势
- 07_03 使用存储过程查询指定课程
- Centos 7 安装完后出现r,q,c等
- OOP编程
- Java窗体透明化(无边框)
- Ubuntu-16.10安装OpenCV3
- JQuery基础的一些解释
- 文章标题