Isn't it 'Easy'?
class Solution {public: int findPoisonedDuration(vector & ts, int d) { int ret = 0, s = 0, e = 0; for(auto t : ts) { if(t > e) { ret += e - s; s = t; } e = t + d; } ret += e - s; return ret; }};
本文共 423 字,大约阅读时间需要 1 分钟。
Isn't it 'Easy'?
class Solution {public: int findPoisonedDuration(vector & ts, int d) { int ret = 0, s = 0, e = 0; for(auto t : ts) { if(t > e) { ret += e - s; s = t; } e = t + d; } ret += e - s; return ret; }};
转载于:https://www.cnblogs.com/tonix/p/6359711.html