leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE | |
commit | 5d90da24072a917af37b6e21bab3489754150bd8 |
parent | e49a9fe8292e3827f2319130769f7884bdbeed65 |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Tue, 23 Jul 2024 20:36:43 +0200 |
Daily Problem
Diffstat:A | Problems/1636.cpp | | | +++++++++++++++++++ |
M | README.md | | | + |
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/Problems/1636.cpp b/Problems/1636.cpp
@@ -0,0 +1,19 @@
class Solution {
public:
vector<int> frequencySort(vector<int> &nums) const {
static int count[201];
memset(count, 0x00, sizeof(count));
for (const int n : nums)
count[n + 100]++;
sort(begin(nums), end(nums), [&](int a, int b) {
const int x = count[a + 100];
const int y = count[b + 100];
return x != y ? x < y : a > b;
});
return nums;
}
};
diff --git a/README.md b/README.md
@@ -908,6 +908,7 @@ for solving problems.
| 1630 | Medium | [Arithmetic Subarrays](Problems/1630.cpp) |
| 1631 | Medium | [Path With Minimum Effort](Problems/1631.cpp) |
| 1633 | Easy | [Percentage of Users Attended a Contest](Problems/1633.cpp) |
| 1636 | Easy | [Sort Array by Increasing Frequency](Problems/1636.cpp) |
| 1637 | Medium | [Widest Vertical Area Between Two Points Containing No Points](Problems/1637.cpp) |
| 1638 | Medium | [Count Substrings That Differ by One Character](Problems/1638.cpp) |
| 1639 | Hard | [Number of Ways to Form a Target String Given a Dictionary](Problems/1639.cpp) |