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. ZOJ3329One Person Game(循环型 数学期望)

    There is a very simple and interesting one-person game. You have 3 dice, namely Die1, Die2 and Die3. ...

  2. WPF 同一窗口内的多线程 UI(VisualTarget)

    WPF 的 UI 逻辑只在同一个线程中,这是学习 WPF 开发中大家几乎都会学习到的经验.如果希望做不同线程的 UI,大家也会想到使用另一个窗口来实现,让每个窗口拥有自己的 UI 线程.然而,就不能让 ...

  3. pat甲级 1154 Vertex Coloring (25 分)

    A proper vertex coloring is a labeling of the graph's vertices with colors such that no two vertices ...

  4. 《DSP using MATLAB》示例Example 8.7

    %% ------------------------------------------------------------------------ %% Output Info about thi ...

  5. 错误:Authentication with old password no longer supported, use 4.1 style passwords.

    今天重新装了系统,mysql connector 使用了官网的最新版本(6.8.3). 启动项目出现标题中的错误.原因大家谷歌. 解决方法,使用低版本的 connector. 我使用的是 6.5.6 ...

  6. Android.mk用法详解

    一.Android.mk介绍 Android.mk是Android提供的一种makefile文件,用来指定诸如编译生成so库名.引用的头文件目录.需要编译的.c/.cpp文件和.a静态库文件等.要掌握 ...

  7. linux查找目录下的所有文件中是否含有某个字符串 (转)

    查找目录下的所有文件中是否含有某个字符串 find .|xargs grep -ri "IBM" 查找目录下的所有文件中是否含有某个字符串,并且只打印出文件名 find .|xar ...

  8. python2.7 + ubuntu14.4 + dlib19.7

    0.首先需要Cmake以及编译C++成python程序的工具 sudo apt-get install libboost-python-dev cmake 1.download dlib19.7 fr ...

  9. Mysql auto_increment总结

    一.为什么InnoDB表要建议用自增列做主键 我们先了解下InnoDB引擎表的一些关键特征: InnoDB引擎表是基于B+树的索引组织表(IOT): 每个表都需要有一个聚集索引(clustered i ...

  10. [python] 使用scikit-learn工具计算文本TF-IDF值

    在文本聚类.文本分类或者比较两个文档相似程度过程中,可能会涉及到TF-IDF值的计算.这里主要讲述基于Python的机器学习模块和开源工具:scikit-learn.        希望文章对你有所帮 ...