Tap here to switch tabs
Problem
Submissions

Problem: Goat Latin

med
30 min
Try to solve the Goat Latin problem.

Statement

You are given a string sentence consisting of words separated by spaces. Convert sentence into Goat Latin according to the following rules:

  • If a word begins with a vowel ('a', 'e', 'i', 'o', or 'u', in either uppercase or lowercase), append "ma" to the end of the word.

  • If a word begins with a consonant (any letter other than a vowel), remove its first letter, append it to the end of the word, and then append "ma".

  • Append the character 'a' to the end of each word based on its 11 based position in the sentence. Specifically, append 11 'a' to the 11st word, 22 'a's to the 22nd word, 33 'a's to the 33rd word, and so on.

Return the resulting string after converting sentence to Goat Latin.

Constraints:

  • 1≤1 \leq sentence.length ≤150\leq 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.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Goat Latin

med
30 min
Try to solve the Goat Latin problem.

Statement

You are given a string sentence consisting of words separated by spaces. Convert sentence into Goat Latin according to the following rules:

  • If a word begins with a vowel ('a', 'e', 'i', 'o', or 'u', in either uppercase or lowercase), append "ma" to the end of the word.

  • If a word begins with a consonant (any letter other than a vowel), remove its first letter, append it to the end of the word, and then append "ma".

  • Append the character 'a' to the end of each word based on its 11 based position in the sentence. Specifically, append 11 'a' to the 11st word, 22 'a's to the 22nd word, 33 'a's to the 33rd word, and so on.

Return the resulting string after converting sentence to Goat Latin.

Constraints:

  • 1≤1 \leq sentence.length ≤150\leq 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.