INFINITY 2K21

can anyone explain the second testcase of MARBLES?

In place of ? put character e. Then string S becomes abcdee and string P becomes ehioee. Now as let’s iterate from the start of P , as a and e are both vowels so 2 moves are required to change vowel e to vowel a as in one move you can change a vowel to consonant and in other move you can change that consonant to the target vowel.After that as h and b are both consonants so we need 2 moves to convert h to b as first we can convert it to a vowel and then to consonant b. After this i can be converted to c in 1 move as i is vowel and c is consonant. After that o can be changed to d in 1 move as o is vowel and d is consonant. After that both the strings have same character so no more moves are required. So the total number of moves is 2+2+1+1=6.