mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-12 22:55:19 +08:00
add: leetcode 0495 solution
This commit is contained in:
16
leetcode/0495.Teemo-Attacking/495.Teemo Attacking.go
Normal file
16
leetcode/0495.Teemo-Attacking/495.Teemo Attacking.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package leetcode
|
||||||
|
|
||||||
|
func findPoisonedDuration(timeSeries []int, duration int) int {
|
||||||
|
var ans int
|
||||||
|
for i := 1; i < len(timeSeries); i++ {
|
||||||
|
t := timeSeries[i-1]
|
||||||
|
end := t + duration - 1
|
||||||
|
if end < timeSeries[i] {
|
||||||
|
ans += duration
|
||||||
|
} else {
|
||||||
|
ans += timeSeries[i] - t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ans += duration
|
||||||
|
return ans
|
||||||
|
}
|
Reference in New Issue
Block a user