Untitled

mail@pastecode.io avatar
unknown
python
2 months ago
562 B
5
Indexable
Never
class Solution:
    def findPoisonedDuration(self, timeSeries: List[int], duration: int) -> int:
        poison_valid = 0
        prev = 0
        curr = 0

        if timeSeries[0] == 0:
            total = duration
        else: 
            total = 0

        for i in range(len(timeSeries)):
            curr = timeSeries[i]

            if poison_valid >= curr:
                total += curr - prev
            else:
                total += duration
            
            poison_valid = curr + duration - 1
            prev = curr

        return total 
Leave a Comment