commit 774e91e7c1e20776bdb75bedd2698a0c795b6da7
parent 3dcd6ec653682dc30a0c923ad5976056a5ee3d2f
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Fri, 17 May 2024 11:57:09 +0200
1 Random Problem
Diffstat:
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/Problems/2559.cpp b/Problems/2559.cpp
@@ -0,0 +1,21 @@
+class Solution {
+ static bool is_vowel(const char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'; }
+
+ public:
+ vector<int> vowelStrings(const vector<string> &words, const vector<vector<int>> &queries) const {
+ static int count[100002];
+ const int n = size(words), m = size(queries);
+
+ memset(count, 0x00, sizeof(count));
+ for (int i = 0, acc = 0; i < n; i++) {
+ if (is_vowel(words[i].front()) && is_vowel(words[i].back())) acc++;
+ count[i + 1] = acc;
+ }
+
+ vector<int> res(m);
+ for (int i = 0; i < m; i++) {
+ res[i] = count[queries[i][1] + 1] - count[queries[i][0]];
+ }
+ return res;
+ }
+};
diff --git a/README.md b/README.md
@@ -1145,6 +1145,7 @@ for solving problems.
| 2545 | Medium | [Sort the Students by Their Kth Score](Problems/2545.cpp) |
| 2551 | Hard | [Put Marbles in Bags](Problems/2551.cpp) |
| 2554 | Medium | [Maximum Number of Integers to Choose From a Range I](Problems/2554.cpp) |
+| 2559 | Medium | [Count Vowel Strings in Ranges](Problems/2559.cpp) |
| 2568 | Medium | [Minimum Impossible OR](Problems/2568.cpp) |
| 2571 | Medium | [Minimum Operations to Reduce an Integer to 0](Problems/2571.cpp) |
| 2579 | Medium | [Count Total Number of Colored Cells](Problems/2579.cpp) |