文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
1. Description
2. Solution
**解析:**按顺序计算提莫的毒性伤害时间即可。
- Version 1
class Solution:
def findPoisonedDuration(self, timeSeries: List[int], duration: int) -> int:
count = duration
n = len(timeSeries)
for i in range(n-1):
if timeSeries[i] duration <= timeSeries[i 1]:
count = duration
else:
count = timeSeries[i 1] - timeSeries[i]
return count
- Version 2
class Solution:
def findPoisonedDuration(self, timeSeries: List[int], duration: int) -> int:
count = duration
n = len(timeSeries)
for i in range(n-1):
count = min(duration, timeSeries[i 1] - timeSeries[i])
return count
Reference
- https://leetcode.com/problems/teemo-attacking/