public class Solution {
public int FindPoisonedDuration(int[] timeSeries, int duration) {
if (timeSeries == null || timeSeries.Length == )
{
return ;
}
else if (timeSeries.Length == )
{
return duration;
}
else
{
var sum = ;
for (int i = ; i < timeSeries.Length - ; i++)
{
var cur = timeSeries[i];
var next = timeSeries[i + ]; if (cur + duration <= next)
{
sum += duration;
}
else
{
sum += next - cur;
}
}
sum += duration;
return sum;
}
}
}

https://leetcode.com/problems/teemo-attacking/#/description

leetcode495的更多相关文章

  1. [Swift]LeetCode495. 提莫攻击 | Teemo Attacking

    In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned ...

  2. 2017-3-4 leetcode 414 485 495

    虽说周末要早起来着,但是日子过得有点奇怪,一不小心就忘掉了... leetcode414 https://leetcode.com/problems/third-maximum-number/?tab ...

随机推荐

  1. HDU1575 Tr A

    解题思路:矩阵快速幂模板题,见代码: #include<cstdio> #include<cstring> #include<algorithm> using na ...

  2. 模块(Modules)

    一.引入模块 模块:当编写更大的应用程序时,所有的代码肯定会分成多个文件,这样便于维护,另外已经编写好的函数和对象在被多个程序中使用时,不用把函数和对象拷贝到每个程序中. 模块支持以上功能,在Pyth ...

  3. C++中atof函数的实现和atoi的实现

    在C++中有两个系统函数可以实现字符串转浮点型和字符串转整形,下面实现一下这两个函数. #include <iostream> #include <string> using ...

  4. linux下vi命令(转)

    进入vi的命令 vi filename :打开或新建文件,并将光标置于第一行首 vi +n filename :打开文件,并将光标置于第n行首 vi + filename :打开文件,并将光标置于最后 ...

  5. BZOJ5196: [Usaco2018 Feb]Taming the Herd(DP暴力)

    5196: [Usaco2018 Feb]Taming the Herd Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 78  Solved: 71[ ...

  6. 通过Excel生成批量SQL语句,处理大量数据的好办法

    我们经常会遇到这样的要求:用户给发过来一些数据,要我们直接给存放到数据库里面,有的是Insert,有的是Update等等,少量的数据我们可以采取最原始的办法,也就是在SQL里面用Insert into ...

  7. mysql 查找多个值并且取最大值一个和分组

    SELECT eco_truename, eco_uid, max(checkup_time) AS time FROM es_checkup_order WHERE checkup_time GRO ...

  8. Oracle 11gR2 RAC集群服务启动与关闭总结

    引言:这写篇文章的出处是因为我的一名学生最近在公司搭建RAC集群,但对其启动与关闭的顺序和原理不是特别清晰,我在教学工作中也发现了很多学员对RAC知识了解甚少,因此我在这里就把RAC里面涉及到的最常用 ...

  9. java nio和bio

    理解同步/异步,阻塞/非阻塞:https://juejin.im/entry/598da7d16fb9a03c42431ed3 2:http://qindongliang.iteye.com/blog ...

  10. JSONUtils的几个常用方法

    1.首先新建1个JSONUtils类 public class JSONUtils { /** * * @author wangwei JSON工具类 * @param * */ /*** * 将Li ...