Suppose we have two strings s and t. We can only change a character at any position to any vowel if it is already a vowel or to a consonant if it is already a consonant. We have to check whether s can be represented to t or vice-versa.
So, if the input is like s = "udpmva", t = "itmmve", then the output will be True as we can transform u -> i, d -> t, p -> m, a -> e
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
def isVowel(x): if x in ['a', 'e', 'i', 'o', 'u']: return True return False def solve(s, t): s_size = len(s) if (s_size != len(t)): return False for i in range(s_size): if (isVowel(s[i]) and isVowel(t[i])): continue elif ((isVowel(s[i])) == False and ( isVowel(t[i]) == False)): continue else: return False return True s, t = "udpgma", "itmmve" print(solve(s, t))