Suppose we have two lowercase strings s and t. Sometimes, when we type a vowel, the key might get long pressed, and the vowel will be repeated 1 or more times. We have to check whether it is possible that t is typed that indicates s or not.
So, if the input is like s = "mine" t = "miiine", then the output will be True as vowel 'i' is repeated three times, other letters are fine.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
def isVowel(c): vowel = "aeiou" return c in vowel def solve(s, t): s_len = len(s) t_len = len(t) j = 0 for i in range(s_len): if s[i] != t[j]: return False if isVowel(s[i]) == False: j = j + 1 continue cnt_1 = 1 while i < s_len - 1 and (s[i] == s[i + 1]): cnt_1 = cnt_1 + 1 i = i + 1 cnt_2 = 1 while j < t_len - 1 and t[j] == s[i]: cnt_2 = cnt_2 + 1 j = j + 1 if cnt_1 > cnt_2: return False return True s = "mine" t = "miiine" print(solve(s, t))