leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

commit 6f0cd157d1fba73dbc349061d479a9c34c21984f
parent 8e6e601a4ca0c1187af15461d397c428f30fb431
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sat,  4 May 2024 11:36:58 +0200

1 Random Problem

Diffstat:
AProblems/2365.cpp | 13+++++++++++++
MREADME.md | 1+
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/Problems/2365.cpp b/Problems/2365.cpp @@ -0,0 +1,13 @@ +class Solution { + public: + long long taskSchedulerII(const vector<int> &tasks, int space) const { + unordered_map<int, long long> um; + long long day = 0; + + for (const int t : tasks) { + um[t] = day = max(day, um[t] + space) + 1; + } + + return day - space; + } +}; diff --git a/README.md b/README.md @@ -1087,6 +1087,7 @@ for solving problems. | 2358 | Medium | [Maximum Number of Groups Entering a Competition](Problems/2358.cpp) | | 2359 | Medium | [Find Closest Node to Given Two Nodes](Problems/2359.cpp) | | 2360 | Hard | [Longest Cycle in a Graph](Problems/2360.cpp) | +| 2365 | Medium | [Task Scheduler II](Problems/2365.cpp) | | 2366 | Hard | [Minimum Replacements to Sort the Array](Problems/2366.cpp) | | 2368 | Medium | [Reachable Nodes With Restrictions](Problems/2368.cpp) | | 2369 | Medium | [Check if There is a Valid Partition For The Array](Problems/2369.cpp) |