Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u'};
- int count = 0;
- for (int i = 0; i + 2 < text.length(); ++i) {
- int vowelCount = 0;
- for (int j = i; j < i + 3; ++j) {
- if (vowels.count(text[j])) {
- vowelCount++;
- }
- }
- if (vowelCount == 2) {
- count++;
- }
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment