国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

495. Teemo Attacking

2019-11-08 01:44:27
字體:
供稿:網(wǎng)友

In LLP world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascending time series towards Ashe and the poisoning time duration per Teemo's attacking, you need to output the total time that Ashe is in poisoned condition.

You may assume that Teemo attacks at the very beginning of a specific time point, and makes Ashe be in poisoned condition immediately.

Example 1:

Input: [1,4], 2Output: 4Explanation: At time point 1, Teemo starts attacking Ashe and makes Ashe be poisoned immediately. This poisoned status will last 2 seconds until the end of time point 2. And at time point 4, Teemo attacks Ashe again, and causes Ashe to be in poisoned status for another 2 seconds. So you finally need to output 4.

Example 2:

Input: [1,2], 2Output: 3Explanation: At time point 1, Teemo starts attacking Ashe and makes Ashe be poisoned. This poisoned status will last 2 seconds until the end of time point 2. However, at the beginning of time point 2, Teemo attacks Ashe again who is already in poisoned status. Since the poisoned status won't add up together, though the second poisoning attack will still work at time point 2, it will stop at the end of time point 3. So you finally need to output 3.

Note:

You may assume the length of given time series array won't exceed 10000.You may assume the numbers in the Teemo's attacking time series and his poisoning time duration per attacking are non-negative integers, which won't exceed 10,000,000.

Subscribe to see which companies asked this question.

public class Solution {    public int findPoisonedDuration(int[] timeSeries, int duration) {        if(timeSeries.length==0)            return 0;        int re=0;        for(int i=0;i<timeSeries.length-1;++i){            if(timeSeries[i+1]-timeSeries[i]>duration)                re+=duration;            else                re+=(timeSeries[i+1]-timeSeries[i]);        }        return re+duration;    }}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 邵阳市| 广河县| 江西省| 个旧市| 合水县| 汉阴县| 明溪县| 景德镇市| 专栏| 武平县| 简阳市| 西充县| 深泽县| 乌兰县| 安顺市| 健康| 江北区| 文登市| 安国市| 汤阴县| 棋牌| 普陀区| 醴陵市| 堆龙德庆县| 尼勒克县| 图们市| 梧州市| 彝良县| 盈江县| 滕州市| 惠安县| 东乡县| 婺源县| 景东| 黔江区| 汉阴县| 靖州| 石屏县| 合山市| 汶川县| 义乌市|