Editorial for DMOPC '21 Contest 10 P1 - Japaneasy


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: 4fecta

There are many possible solutions to this problem. The simplest is to group the characters into two categories, vowels (aiueo) and consonants (knhfmr). Then, iterate through the string from left to right. If the current character is a vowel, we move one index forwards. Otherwise, if it's a consonant, we check that the next character is a vowel and move two indices forwards if it is. The word is then valid if and only if we reach the end of the string. Of course, careful attention should be paid to the details of handling the fu case.

Time Complexity: O(N) where N is the length of the string.


Comments

There are no comments at the moment.