leetcode495
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的更多相关文章
- [Swift]LeetCode495. 提莫攻击 | Teemo Attacking
In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned ...
- 2017-3-4 leetcode 414 485 495
虽说周末要早起来着,但是日子过得有点奇怪,一不小心就忘掉了... leetcode414 https://leetcode.com/problems/third-maximum-number/?tab ...
随机推荐
- Python源码分析(一)
最近想学习下Python的源码,希望写个系列博客,记录的同时督促自己学习. Python源码目录 从Python.org中下载源代码压缩包并解压,我下载的是Python2.7.12,解压后: 对于主要 ...
- 【剑指offer】不分行从上到下打印二叉树,C++实现(层序遍历)
原创文章,转载请注明出处! 本题牛客网地址 博客文章索引地址 博客文章中代码的github地址 1.题目 从上往下打印出二叉树的每个节点,同层节点从左至右打印.例如: 图 不分行从上往下按层打印二叉 ...
- Ubuntu中apt-get安装或更新软件错误的解决办法
$su #apt-get clean #cd /var/lib/apt #mv lists lists.back #mkdir -p lists/partial #apt-get clean #apt ...
- BloomFilter ——大规模数据处理利器
BloomFilter——大规模数据处理利器 Bloom Filter是由Bloom在1970年提出的一种多哈希函数映射的快速查找算法.通常应用在一些需要快速判断某个元素是否属于集合,但是并不严格要求 ...
- #Eclipse web工程 部署 三种方式 3
Eclipse web工程 部署 三种方式 3.热部署 在Eclipse中,实现 修改一个.java文件或者.jsp文件甚至是配置文件,不需要重启WEB服务器的前提下让修改生效,实现tomcat自动加 ...
- new Date()相关获取当月天数和当月第一天
var myDate = new Date(); //获取本月第一天周几 var monthFirst = new Date(myDate.getFullYear(), parseInt(myDat ...
- ruby 的数组操作
转自:http://fujinbing.iteye.com/blog/1126232 1. & [ 1, 1, 3, 5 ] & [ 1, 2, 3 ] # => [1, 3] ...
- LeetCode 549. Binary Tree Longest Consecutive Sequence II
原题链接在这里:https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii/description/ 题目: G ...
- matplotlib ----- 多子图, subplots
这一篇讲的比较详细. http://matplotlib.org/examples/pylab_examples/subplots_demo.html 官方文档给出的subplots用法, http: ...
- C#类、方法的访问修饰符
这篇文章主要介绍了C#类的访问修饰符用法,较为详细的分析了C#类的访问修饰符概念与用法,具有一定的参考借鉴价值,需要的朋友可以参考下 本文详细分析了C#类的访问修饰符用法,分享给大家供大家参考.具体用 ...