Python O(n) Simple Solution

  • 0
    def findPoisonedDuration(self, timeSeries, duration):
            n = len(timeSeries)
            total = 0
            for i in range(0, n-1):
                total += min(duration, timeSeries[i+1] - timeSeries[i])
            return total + duration if n else 0

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.