leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE | |
commit | cfea103a9fe86ffa217009c1fad8b5dc28524bdc |
parent | af407a9527e955088a16bd38ae884a5a843ed5a4 |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Thu, 13 Jun 2024 13:54:28 +0200 |
Daily Problem
Diffstat:A | Problems/2037.cpp | | | ++++++++++++++++++++ |
M | README.md | | | + |
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/Problems/2037.cpp b/Problems/2037.cpp
@@ -0,0 +1,20 @@
class Solution {
public:
int minMovesToSeat(const vector<int> &seats, const vector<int> &students) const {
static int count[101];
memset(count, 0x00, sizeof(count));
for (const int n : seats)
count[n]++;
for (const int n : students)
count[n]--;
int res = 0, unmatched = 0;
for (int n : count) {
res += abs(unmatched);
unmatched += n;
}
return res;
}
};
diff --git a/README.md b/README.md
@@ -1024,6 +1024,7 @@ for solving problems.
| 2023 | Medium | [Number of Pairs of Strings With Concatenation Equal to Target](Problems/2023.cpp) |
| 2024 | Medium | [Maximize the Confusion of an Exam](Problems/2024.cpp) |
| 2033 | Medium | [Minimum Operations to Make a Uni-Value Grid](Problems/2033.cpp) |
| 2037 | Easy | [Minimum Number of Moves to Seat Everyone](Problems/2037.cpp) |
| 2038 | Medium | [Remove Colored Pieces if Both Neighbors are the Same Color](Problems/2038.cpp) |
| 2039 | Medium | [The Time When the Network Becomes Idle](Problems/2039.cpp) |
| 2043 | Medium | [Simple Bank System](Problems/2043.cpp) |