Editorial for Riolku's Mock CCC S1 - Word Bot

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

Author: maxcruickshanks

Subtask 1

We can maintain a counter for the amount of consecutive vowels and the amount of consecutive consonants.

When we encounter a vowel, we increment the vowel counter and reset the consonant counter.

When we encounter a consonant, we increment the consonant counter and reset the vowel counter.

If we ever go over the threshold of C consonants or V vowels, output NO; otherwise, output YES.

Time Complexity: \mathcal{O}(N)

Subtask 2

Use the previous idea except we account for the y case.

When we encounter a y, increment both counters and do not reset either of them.

Time Complexity: \mathcal{O}(N)


There are no comments at the moment.