495. Teemo Attacking
来源:互联网 发布:淘宝主营类目占比影响 编辑:程序博客网 时间:2024/05/05 18:38
题目大概意思是 LLP游戏中,Teemo 攻击 Ashe,会使Ashe处于中毒状态,状态持续时间是n,输入一组数组【1,2,5,6】代表在每个时间点Teemo发起攻击,输入一个常数n代表中毒的持续时间,输出Ashe处于中毒状态的时间和。
例1:
Input: [1,4], 2Output: 4
[1,4]代表Teemo在1和4这个时间点发起攻击,2代表持续时间,那么输出4代表处于中毒的时间和(1-3,4-6).
代码:
public class Solution { public int findPoisonedDuration(int[] timeSeries, int duration) { if(timeSeries.length == 0) return 0; int length = timeSeries.length; int time = 0; for(int i = 0; i < length-1 ; i++){ int tmp = timeSeries[i+1]-timeSeries[i]; time = time+Math.min(tmp,duration); //中毒的叠加状态时间等于前后攻击的间隔和中毒的持续时间的最小值的叠加。 } time = time+duration; return time; }}
0 0
- 495. Teemo Attacking
- LeetCode 495. Teemo Attacking
- LeetCode 495. Teemo Attacking
- 495. Teemo Attacking
- 495. Teemo Attacking
- 495. Teemo Attacking
- LeetCode:495. Teemo Attacking
- 【Leetcode】495. Teemo Attacking
- 495. Teemo Attacking
- [Array]495. Teemo Attacking
- 495. Teemo Attacking
- [leetcode] 495. Teemo Attacking
- 495. Teemo Attacking
- 495. Teemo Attacking
- leetcode 495. Teemo Attacking
- 【LeetCode】495. Teemo Attacking
- LeetCode 495. Teemo Attacking
- 495. Teemo Attacking
- Tomcat和IIS整合过程—下—JDK和Tomcat装
- MySql绿色版配置及使用详解
- javascript重点-表达式和运算符_优就业
- NSWOJ 1160 鸡兔同笼
- 关于Git的使用初步了解
- 495. Teemo Attacking
- 1051
- Android adb连接不上解决办法
- python爬虫——爬取链家房价信息(未完待续)
- 聊聊分布式一致性之CAP理论和BASE理论
- 数据可视化工具让工作变简单
- 编写一个程序,它从标准输入读取C源代码,并验证所有的花括号都正确的成对出现
- 欢迎使用CSDN-markdown编辑器
- 新手小白安装OpenCV的问题总结