leetcode

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

commit 4519fb1fb5218a3b9ee91819dc3475b3828c73b9
parent c2b2bf3f3dd0e0a998f0a49674e2d4def1348b5e
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sat, 12 Oct 2024 09:42:53 +0200

Daily Problem

Diffstat:
AProblems/2406.cpp | 23+++++++++++++++++++++++
MREADME.md | 1+
2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/Problems/2406.cpp b/Problems/2406.cpp @@ -0,0 +1,23 @@ +class Solution { + public: + int minGroups(vector<vector<int>> &intervals) const { + static int start[1000001], end[1000001]; + int res = 1; + + memset(end, 0x00, sizeof(end)); + memset(start, 0x00, sizeof(start)); + + for (const auto &inter : intervals) { + start[inter[0]]++; + end[inter[1]]++; + } + + for (int i = 1, acc = 0; i <= 1000000; i++) { + acc += start[i]; + res = max(res, acc); + acc -= end[i]; + } + + return res; + } +}; diff --git a/README.md b/README.md @@ -1214,6 +1214,7 @@ for solving problems. | 2401 | Medium | [Longest Nice Subarray](Problems/2401.cpp) | | 2402 | Hard | [Meeting Rooms III](Problems/2402.cpp) | | 2405 | Medium | [Optimal Partition of String](Problems/2405.cpp) | +| 2406 | Medium | [Divide Intervals Into Minimum Number of Groups](Problems/2406.cpp) | | 2410 | Medium | [Maximum Matching of Players With Trainers](Problems/2410.cpp) | | 2414 | Medium | [Length of the Longest Alphabetical Continuous Substring](Problems/2414.cpp) | | 2415 | Medium | [Reverse Odd Levels of Binary Tree](Problems/2415.cpp) |