国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 高清| 通化市| 曲松县| 乌鲁木齐市| 通城县| 宁夏| 沂源县| 凤冈县| 湟源县| 明星| 渭源县| 循化| 乌审旗| 清水县| 上思县| 周口市| 唐山市| 关岭| 南木林县| 威远县| 莱西市| 寿阳县| 平江县| 石渠县| 南通市| 隆回县| 象州县| 奇台县| 阿拉尔市| 乐清市| 日照市| 太康县| 金乡县| 仁怀市| 平江县| 根河市| 夹江县| 平谷区| 绥阳县| 延寿县| 莎车县|