commit 529a210ad051b5721494155ade76c0c8432abecd
parent 8a16ebbaffbff220b3207ef55188b3855109c828
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Wed, 11 Oct 2023 19:48:54 +0000
Daily Problem
Diffstat:
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/Problems/2251.cpp b/Problems/2251.cpp
@@ -0,0 +1,24 @@
+class Solution {
+ public:
+ vector<int> fullBloomFlowers(const vector<vector<int>> &flowers, const vector<int> &people) const {
+ vector<int> start, finish, res;
+
+ start.reserve(flowers.size());
+ finish.reserve(flowers.size());
+ for (const auto &flower : flowers) {
+ start.push_back(flower[0]);
+ finish.push_back(flower[1] + 1);
+ }
+
+ sort(begin(start), end(start));
+ sort(begin(finish), end(finish));
+
+ res.reserve(people.size());
+ for (const int person : people) {
+ const int left = upper_bound(begin(start), end(start), person) - begin(start);
+ const int right = upper_bound(begin(finish), end(finish), person) - begin(finish);
+ res.push_back(left - right);
+ }
+ return res;
+ }
+};
diff --git a/README.md b/README.md
@@ -778,6 +778,7 @@ for solving problems.
| 2243 | Easy | [Calculate Digit Sum of a String](Problems/2243.cpp) |
| 2244 | Medium | [Minimum Rounds to Complete All Tasks](Problems/2244.cpp) |
| 2246 | Hard | [Longest Path With Different Adjacent Characters](Problems/2246.cpp) |
+| 2251 | Hard | [Number of Flowers in Full Bloom](Problems/2251.cpp) |
| 2265 | Medium | [Count Nodes Equal to Average of Subtree](Problems/2265.cpp) |
| 2272 | Hard | [Substring With Largest Variance](Problems/2272.cpp) |
| 2275 | Medium | [Largest Combination With Bitwise AND Greater Than Zero](Problems/2275.cpp) |