Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions C++/1353.c++
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class Solution {
public:
static bool cmp(vector<int>&a,vector<int>&b){
if(a[1]<b[1])return true;
else if(a[1]==b[1])return a[0]<b[0];
return false;
}
int maxEvents(vector<vector<int>>& events) {
sort(events.begin(), events.end(),cmp);
int cnt = 0;
set<int> days;
for(int i = 1; i <= 100000; ++i) days.insert(i);
for(const auto & event : events) {
int s = event[0], e = event[1] ;
auto it = days.lower_bound(s);
if(it == days.end() || *it > e) {
continue;
} else {
++cnt;
days.erase(it);
}
}
return cnt;
}
};
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ Or from the Sheet 1 of this [Google Sheet](https://bit.ly/2EUhwnw)
| 0983 | [Minimum Cost For Tickets](https://leetcode.com/problems/minimum-cost-for-tickets/) | Here dp(i) is the cost to travel from day days[i] to the end of the plan. if days[j] < days[i] + 1 then j1=j. if days[j] < days[i] + 7 then j=j7. if days[j] < days[i] + 30 then j=j30 . dp(i)=min(dp(j1)+costs[0],dp(j7)+costs[1],dp(j30)+costs[2]) | [Java](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/Java/0983.java) | O(n) | O(n) | Medium | Dynamic Programming | [📺](https://www.youtube.com/watch?v=2AnrAlCA578) |
| 1347 | [Minimum Number of Steps to Make Two Strings Anagram](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram/) | Add 1 for char in s and remove 1 for char in t | [Java](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/Java/1347.java) [Python](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/Python/1347.py) | O(n+m) | O(1) | Medium | Hash Table Heap | [📺](https://www.youtube.com/watch?v=xXXOpOYWtRE) |
| 1352 | [Product of the Last K Numbers](https://leetcode.com/problems/product-of-the-last-k-numbers/) | Add new element to list by multiplying it with previous number and return arr[n-1]/arr[n-k-1] | [Python](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/Python/1352.py) | O(1) | O(1) | Medium | Array Design | [📺](https://www.youtube.com/watch?v=8CuVduv0Kyg) |
| 1353 | [Maximum no of events that can be attended](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended/) | You can attend an event i at any day d where startTimei <= d <= endTimei. Notice that you can only attend one event at any time d.Return the maximum number of events you can attend | [C++](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/Python/1353.c++) | O(n*m) | O(n) | Medium | Array Deesign | [📺](https://www.youtube.com/watch?v=UktCMArqmPA) |


Format