Rövarspråket
InterviewTime limit1sMemory limit1024 MB
Given an original word and Oskar's word, decide whether encoding some consonants of the original as x-o-x can produce Oskar's word.
- Level
Easy3 of 10
- Topics
- String, Two pointers
- Solved
- No attempts yet
Problem
Rövarspråket is a way of encoding text. Every consonant is replaced with o, and every vowel stays unchanged. For example, hej becomes hohejoj, moo becomes momoo, and ojoj becomes ojojojoj.
Oskar has just learned rövarspråket, but he sometimes forgets to change some consonants. So Oskar only translates a subset of the consonants in the way described above. You are given an original text and a possible translation that Oskar wrote. Determine whether Oskar could have translated the first string into the second one as described above.
If Oskar wrote hejoj, the original text could have been hej or hejoj. For clarity, the vowels are defined as a,e,i,o,u,y, and all other letters are consonants.
Input
The first line contains the word that may be the original text. The second line contains a word that Oskar wrote. Both words contain at least one character and only the characters a-z, all lowercase. No string is longer than 1000 characters.
Output
Output a single word: ja if the second word could be a translation of the first word, otherwise nej. The answer is ja if and only if some subset of the consonants in the first word can be transformed with the rövarspråk rule to produce the second word.
Hint
In the first example, it does not matter which consonant Oskar chooses to transform, as long as he chooses exactly one of the j letters. Suppose Oskar forgot to transform all j except the first one. Then ojojoj becomes ojojojoj. The answer is ja.
In the second example, the translation is impossible. The first string has two j letters next to each other, and those two j letters always stay next to each other. So the first string cannot be transformed into the second one, and the answer is nej.