Skip to content

Commit fed6f4d

Browse files
authored
Merge branch 'master' into master
2 parents c273465 + d7fe666 commit fed6f4d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

C++/teemo-attacking.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//https://leetcode.com/problems/teemo-attacking/
2+
//Difficulty Level: Medium
3+
//Tags: Arrays
4+
//Time complexity: O(n)
5+
//Space complexity: O(1)
6+
//similar to overlapping subintervals problems
7+
8+
class Solution {
9+
public:
10+
int findPoisonedDuration(vector<int>& timeSeries, int duration) {
11+
12+
int n = timeSeries.size();
13+
if(n==0)
14+
return 0;
15+
16+
int ans = duration;
17+
18+
for(int i=0; i<n-1; i++)
19+
{
20+
ans += duration;
21+
if(timeSeries[i+1] < timeSeries[i] + duration) //overlapping condition
22+
{
23+
ans -= (timeSeries[i] + duration - timeSeries[i+1]); //the overlapped time subtracted
24+
}
25+
}
26+
27+
return ans;
28+
}
29+
};

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ Check out ---> [Sample PR](https://github.com/codedecks-in/LeetCode-Solutions/pu
100100
| 811 | [Subdomain Visit Count](https://leetcode.com/problems/subdomain-visit-count/) | [Javascript](./JavaScript/Subdomain-Visit-Count.js) | _O(N*M)_ | _O(N*M + N)_ | Easy | | |
101101
| 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray/) | [C++](./C++/maximum-subarray.cpp) | _O(N)_ | _O(1)_ |Easy | Array | |
102102
| 1 | [Two Sum](https://leetcode.com/problems/two-sum/) | [C++](./C++/two-sum.cpp) | _O(N^2)_ | _O(1)_ |Easy | Array | |
103+
| 495 | [Teemo Attacking](https://leetcode.com/problems/teemo-attacking) | [C++](./C++/teemo-attacking.cpp) | _O(n)_ | _O(1)_ | Medium| Array | |
103104

104105
<br/>
105106
<div align="right">
@@ -361,6 +362,10 @@ DISCLAIMER: This above mentioned resources have affiliate links, which means if
361362
| [Ishika Goel](https://github.com/ishikagoel5628) <br> <img src="https://github.com/Nour-Grati.png" width="100" height="100"> | India | C++ | [Leetcode](https://leetcode.com/ishikagoel5628/) |
362363
| [Fenil Dobariya](https://github.com/ifenil) <br> <img src="https://rb.gy/iascx3" width="100" height="100"> | India | Java | [Github](https://github.com/ifenil) |
363364
| [Prashansa Tanwar](https://github.com/prashansatanwar) <br> <img src="https://github.com/prashansatanwar.png" width="100" height="100"> | India | C++ | [Leetcode](https://leetcode.com/prashansaaa/) |
365+
|[Avinash Trivedi](https://github.com/trivediavinash) <br> <img src="https://github.com/trivediavinash.png" width="100" height="100"> |India | C++ | [Leetcode](https://leetcode.com/avi_002/) |
366+
|[Ishika Goel](https://github.com/ishikagoel5628) <br> <img src="https://github.com/Nour-Grati.png" width="100" height="100"> | India | C++ | [Leetcode](https://leetcode.com/ishikagoel5628/) |
367+
|[Prashansa Tanwar](https://github.com/prashansatanwar) <br> <img src="https://github.com/prashansatanwar.png" width="100" height="100"> | India | C++ | [Leetcode](https://leetcode.com/prashansaaa/) |
368+
|[Ishu Raj](https://github.com/ir2010) <br> <img src="https://github.com/ir2010.png" width="100" height="100"> | India | C++ | [Leetcode](https://leetcode.com/ishuraj2010/) |
364369

365370

366371
<br/>

0 commit comments

Comments
 (0)