1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| // @Title: 提莫攻击 (Teemo Attacking)
// @Author: 15816537946@163.com
// @Date: 2021-11-10 00:55:29
// @Runtime: 32 ms
// @Memory: 6.6 MB
func findPoisonedDuration(timeSeries []int, duration int) int {
var pre,ans int
for _, t := range timeSeries {
if t >= pre {
ans += duration
} else {
ans += t + duration - pre
}
pre = t + duration
}
return ans
}
|