Description

Convert a sentence to Goat Latin: words starting with vowels add "ma", others move first letter to end + "ma", then add "a" repeated by word index. Return the result as a string.

Examples

Input:sentence = "I speak Goat Latin"
Output:"Imaa peaksmaaa oatGmaaaa atinLmaaaaa"
Explanation:

'I' starts with vowel: I + ma + a = Imaa. 'speak' starts with consonant: peak + s + ma + aa = speakmaa. 'Goat' -> oat + G + ma + aaa = oatGmaaa. 'Latin' -> atin + L + ma + aaaa = atinLmaaaa.

Input:sentence = "a"
Output:"amaa"
Explanation:

A single-word sentence is converted to Goat Latin by applying the vowel/consonant rule and appending 'a' characters.

Input:The quick brown fox
Output:heTmaa uickqmaaa rownbmaaaa oxfmaaaaa
Explanation:

Each word is converted to Goat Latin: consonant-starting words move the first consonant to the end and add 'ma' plus 'a's equal to the word position, while vowel-starting words just add 'ma' plus the position-based 'a's.

Constraints

  • 1 ≤ sentence.length ≤ 150

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!