EasyNo. 0495
Teemo Attacking — LeetCode 495 Python Solution
- Topics
- Array, Simulation
- Reading time
- 2 min
- Source
- leetcode.com
The problem
Our hero Teemo is attacking an enemy Ashe with poison attacks! When Teemo attacks Ashe, Ashe gets poisoned for a exactly duration seconds.
Example
- Input
- timeSeries = [1,4], duration = 2
- Output
- 4
- Explanation
- Teemo's attacks on Ashe go as follows:
Python solution
class Solution:
def findPoisonedDuration(self, timeSeries: List[int], duration: int) -> int:
ans = duration
for a, b in pairwise(timeSeries):
ans += min(duration, b - a)
return ansComplexity
- Time
- O(n)
- Space · auxiliary
- O(1) to O(n)
Related problems
| No. | Problem | Difficulty |
|---|---|---|
| 0985 | Sum of Even Numbers After Queries | Medium |
| 1389 | Create Target Array in the Given Order | Easy |
| 1409 | Queries on a Permutation With Key | Medium |
| 1503 | Last Moment Before All Ants Fall Out of a Plank | Medium |
| 1535 | Find the Winner of an Array Game | Medium |
| 1560 | Most Visited Sector in a Circular Track | Easy |
Frequently asked questions
- How hard is LeetCode 495. Teemo Attacking?
LeetCode 495. Teemo Attacking is rated Easy on LeetCode.
- What topics does LeetCode 495. Teemo Attacking cover?
LeetCode 495. Teemo Attacking is tagged Array and Simulation on LeetCode.