Practice Goat Latin
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Convert each space-separated word of sentence, preserving its letter case. If its first letter is a vowel (a, e, i, o or u, ignoring case), append ma. Otherwise move the first letter to the end and append ma. Then append one a for the first word, two for the second, and so on. Join the transformed words with spaces and return the result.
Source: Goat Latin on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
sentence = "I speak Goat Latin"
Output
"Imaa peaksmaaa oatGmaaaa atinLmaaaaa"
# Example 2
Input
sentence = "The quick brown fox jumped over the lazy dog"
Output
"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa"
Constraints
1 <= sentence.length <= 150
sentence consists of English letters and spaces.
sentence has no leading or trailing spaces.
All the words in sentence are separated by a single space.
Related LeetCode Problems
Practice more problems similar to Goat Latin.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.