leetcode

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

commite49a9fe8292e3827f2319130769f7884bdbeed65
parentcb13a928c30437e4c11bab9084b3fb3deaa838d2
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateMon, 22 Jul 2024 19:53:41 +0200

Daily Problem

Diffstat:
AProblems/2418.cpp|+++++++++++++++++
MREADME.md|+

2 files changed, 18 insertions(+), 0 deletions(-)


diff --git a/Problems/2418.cpp b/Problems/2418.cpp

@@ -0,0 +1,17 @@

class Solution {
public:
vector<string> sortPeople(vector<string> &names, vector<int> &heights) const {
static int idxes[1001];
const int n = size(names);
iota(idxes, idxes + n, 0);
sort(idxes, idxes + n, [&](int a, int b) { return heights[a] > heights[b]; });
vector<string> res(n);
for (int i = 0; i < n; i++) {
res[i] = names[idxes[i]];
}
return res;
}
};

diff --git a/README.md b/README.md

@@ -1161,6 +1161,7 @@ for solving problems.

| 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) |
| 2418 | Easy | [Sort the People](Problems/2418.cpp) |
| 2421 | Medium | [Number of Good Paths](Problems/2421.cpp) |
| 2423 | Easy | [Remove Letter To Equalize Frequency](Problems/2423.cpp) |
| 2424 | Medium | [Longest Uploaded Prefix](Problems/2424.cpp) |