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

首頁 > 學院 > 開發設計 > 正文

LeetCode題解:Teemo Attacking

2019-11-14 10:56:05
字體:
來源:轉載
供稿:網友

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.

思路:首先假定所有時間下的攻擊都帶來完全的中毒,之后再把重復的地方去掉。題解:
int findPoisonedDuration(const std::vector<int>& timeSeries, int duration) {    int accumulated = duration * timeSeries.size();    int lastAttackEnd = std::numeric_limits<int>::min();    for(auto time: timeSeries) {        if (lastAttackEnd > time) {            accumulated -= lastAttackEnd - time;        }        lastAttackEnd = time + duration;    }    return accumulated;}
上一篇:關于友元函數

下一篇:文章標題

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 墨竹工卡县| 绥棱县| 囊谦县| 西充县| 新沂市| 湟中县| 蒲城县| 衡山县| 稻城县| 紫金县| 塘沽区| 顺平县| 平和县| 漯河市| 建水县| 肃北| 彩票| 绩溪县| 扬州市| 伊金霍洛旗| 特克斯县| 长治市| 徐水县| 和田县| 铁力市| 满洲里市| 藁城市| 广宁县| 五大连池市| 海伦市| 全南县| 百色市| 永仁县| 咸宁市| 大足县| 固始县| 盐山县| 丽江市| 隆子县| 义马市| 澄迈县|