Python | Easy | Array |  Teemo Attacking
\nsee the Successfully Accepted Submission\nPython\nclass Solution(object):\n    def findPoisonedDuration(self, timeSeries, duration):\n        """\n        :ty
\n[see the Successfully Accepted Submission](https://leetcode.com/submissions/detail/944250900/)\n```Python\nclass Solution(object):\n    def findPoisonedDuration(self, timeSeries, duration):\n        """\n        :type timeSeries: List[int]\n        :type duration: int\n        :rtype: int\n        """\n        t=0\n        poisonedSeconds = duration * len(timeSeries)\n        \n        for time in range(1,len(timeSeries)):\n            timeInterval=timeSeries[time]\n            timeInterval_prev=timeSeries[time-1]\n            poisonedSeconds -= max(t, duration - (timeInterval - timeInterval_prev))\n            \n        return poisonedSeconds\n```\n\n**Intuituin**\n \n Initialize a variable \'t\' to 0. This will keep track of the time elapsed.\n```\n        t = 0\n```\nCalculate the total poisoned seconds by multiplying \'duration\' with the number of time intervals in \'timeSeries\'.\n```\n        poisonedSeconds = duration * len(timeSeries)\n```\nIterate through \'timeSeries\' starting from the second element (index 1).\n```\n        for time in range(1, len(timeSeries)):\n```\nGet the current time interval and the previous time interval.\n```\n            timeInterval = timeSeries[time]\n            timeInterval_prev = timeSeries[time - 1]\n```      \nCalculate the difference between the current time interval and the previous one.\n```\n            timeDiff = timeInterval - timeInterval_prev\n```\n Calculate the time the person is not poisoned during this interval by taking the maximum of \'t\' and subtracting the time remaining in the current interval (\'duration - timeDiff\').\n```\n            notPoisonedTime = max(t, duration - timeDiff)\n```  \nSubtract the \'notPoisonedTime\' from \'poisonedSeconds\'.\n```\n            poisonedSeconds -= notPoisonedTime\n```\n![image](https://assets.leetcode.com/users/images/b1e4af48-4da1-486c-bc97-b11ae02febd0_1696186577.992237.jpeg)\n
['Array', 'Python']