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 ...
随机推荐
- js之验证码倒计时功能
<!DOCTYPE html> <html > <head> <meta http-equiv="Content-Type" conten ...
- 实战maven私有仓库三部曲之二:上传到私有仓库
在上一章<实战maven私有仓库三部曲之一:搭建和使用>我们搭建了maven私有仓库,并体验了私有仓库缓存jar包的能力,避免了局域网内开发人员去远程中央仓库下载的痛苦等待,本章我们再来体 ...
- bytes 与 str的区别以及装换
bytes 和 str 的区别: bytes 存储字节( 通常值在 range(0, 256)) str 存储unicode字符( 通常值在0~65535) bytes 与 str 的转换 编码(en ...
- sudo 运行 npm或node时,出现找不到命令
sudo 运行 npm或node时,出现找不到命令的情况,运行下面这些命令, sudo ln -s /usr/local/bin/node /usr/bin/node sudo ln -s /usr/ ...
- 每天一个linux命令:【转载】rm命令
今天学习一下linux中删除文件和目录的命令: rm命令.rm是常用的命令,该命令的功能为删除一个目录中的一个或多个文件或目录,它也可以将某个目录及其下的所有文件及子目录均删除.对于链接文件,只是删除 ...
- ubuntu scrapy 开发环境搭建
我的版本是14.04 1.更新系统 ##如果系统没有换国内下载路径需要换下系统的更新下载路径 http://www.cnblogs.com/seablog/p/7043798.html sudo a ...
- Elixir's keyword lists as option parameters
备注: 文章转自:https://www.djm.org.uk/posts/writing-extensible-elixir-with-behaviours-adapters-pluggable-b ...
- parcel vue 简单使用
1.安装依赖 yarn global add parcel-bundler yarn add babel-preset-env --dev yarn add parcel-plugin-vue --d ...
- openresty 使用 log_by_lua 发送日志到 syslog-ng
1. 安装 opm get p0pr0ck5/lua-resty-logger-socket 2. 使用 location lua_by_lua_block log_by_lu ...
- 微软Enterprise Library 4.1和Unity 1.2
说明 微软模式与实践团队今天发布了Enterprise Library 4.1和Unity 1.2版本,这次发布的主要新特性如下: 1. 支持Visual Studio 2008 SP1 2. Uni ...