Python, 1-line straightforward and concise solution


  • 2

    Just calculate sum(min(duration, next attack time - this attack time))

    def findPoisonedDuration(self, s, d):
            return sum(min(d, b - a) for a, b in zip(s, s[1:] + [10e7]))

Log in to reply
 

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