1 Random Problem
Diffstat:
2 files changed, 22 insertions(+), 0 deletions(-)
@@ -0,0 +1,21 @@
class Solution {
static inline bool isVowel(const char c) {
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
public:
int beautifulSubstrings(const string &s, int k) const {
const int n = s.size();
int res = 0;
for (int i = 0; i < n; i++) {
int vowels = 0, consonants = 0;
for (int j = i; j < n; j++) {
isVowel(s[j]) ? vowels++ : consonants++;
if (vowels != consonants) continue;
if ((vowels * consonants) % k != 0) continue;
res++;
}
}
return res;
}
};
@@ -923,3 +923,4 @@
for solving problems.
| 2856 | Medium | [Minimum Array Length After Pair Removals](Problems/2856.cpp) |
| 2895 | Medium | [Minimum Processing Time](Problems/2895.cpp) |
| 2900 | Medium | [Longest Unequal Adjacent Groups Subsequence I](Problems/2900.cpp) |
| 2947 | Medium | [Count Beautiful Substrings I](Problems/2947.cpp) |