|
11 | 11 |
|
12 | 12 | ## 495. Teemo Attacking (Medium)
|
13 | 13 |
|
14 | | -<p> |
15 | | -In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking <b>ascending</b> time series towards Ashe and the poisoning time duration per Teemo's attacking, you need to output the total time that Ashe is in poisoned condition. |
16 | | -</p> |
| 14 | +<p>In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking <b>ascending</b> time series towards Ashe and the poisoning time duration per Teemo's attacking, you need to output the total time that Ashe is in poisoned condition.</p> |
17 | 15 |
|
18 | 16 | <p>You may assume that Teemo attacks at the very beginning of a specific time point, and makes Ashe be in poisoned condition immediately.</p>
|
19 | 17 |
|
20 | | -<p><b>Example 1:</b><br /> |
| 18 | +<p><b>Example 1:</b></p> |
| 19 | + |
21 | 20 | <pre>
|
22 | 21 | <b>Input:</b> [1,4], 2
|
23 | 22 | <b>Output:</b> 4
|
24 | | -<b>Explanation:</b> At time point 1, Teemo starts attacking Ashe and makes Ashe be poisoned immediately. <br />This poisoned status will last 2 seconds until the end of time point 2. <br />And at time point 4, Teemo attacks Ashe again, and causes Ashe to be in poisoned status for another 2 seconds. <br />So you finally need to output 4. |
| 23 | +<b>Explanation:</b> At time point 1, Teemo starts attacking Ashe and makes Ashe be poisoned immediately. |
| 24 | +This poisoned status will last 2 seconds until the end of time point 2. |
| 25 | +And at time point 4, Teemo attacks Ashe again, and causes Ashe to be in poisoned status for another 2 seconds. |
| 26 | +So you finally need to output 4. |
25 | 27 | </pre>
|
26 | | -</p> |
27 | 28 |
|
| 29 | +<p> </p> |
| 30 | + |
| 31 | +<p><b>Example 2:</b></p> |
28 | 32 |
|
29 | | -<p><b>Example 2:</b><br /> |
30 | 33 | <pre>
|
31 | 34 | <b>Input:</b> [1,2], 2
|
32 | 35 | <b>Output:</b> 3
|
33 | | -<b>Explanation:</b> At time point 1, Teemo starts attacking Ashe and makes Ashe be poisoned. <br />This poisoned status will last 2 seconds until the end of time point 2. <br/>However, at the beginning of time point 2, Teemo attacks Ashe again who is already in poisoned status. <br/>Since the poisoned status won't add up together, though the second poisoning attack will still work at time point 2, it will stop at the end of time point 3. <br/>So you finally need to output 3. |
| 36 | +<b>Explanation:</b> At time point 1, Teemo starts attacking Ashe and makes Ashe be poisoned. |
| 37 | +This poisoned status will last 2 seconds until the end of time point 2. |
| 38 | +However, at the beginning of time point 2, Teemo attacks Ashe again who is already in poisoned status. |
| 39 | +Since the poisoned status won't add up together, though the second poisoning attack will still work at time point 2, it will stop at the end of time point 3. |
| 40 | +So you finally need to output 3. |
34 | 41 | </pre>
|
35 | | -</p> |
36 | 42 |
|
| 43 | +<p> </p> |
| 44 | + |
| 45 | +<p><b>Note:</b></p> |
37 | 46 |
|
38 | | -<p><b>Note:</b><br> |
39 | 47 | <ol>
|
40 | | -<li>You may assume the length of given time series array won't exceed 10000.</li> |
41 | | -<li>You may assume the numbers in the Teemo's attacking time series and his poisoning time duration per attacking are non-negative integers, which won't exceed 10,000,000.</li> |
| 48 | +<li>You may assume the length of given time series array won't exceed 10000.</li> |
| 49 | +<li>You may assume the numbers in the Teemo's attacking time series and his poisoning time duration per attacking are non-negative integers, which won't exceed 10,000,000.</li> |
42 | 50 | </ol>
|
43 | | -</p> |
| 51 | + |
| 52 | +<p> </p> |
44 | 53 |
|
45 | 54 | ### Related Topics
|
46 | 55 | [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
|
|
0 commit comments