Goat Latin

EasyStringssimulation

Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.

Practice this as a mock interviewFree to start, no account needed

Problem

You are given a sentence made of words separated by single spaces, where each word contains only uppercase and lowercase English letters. Convert it to Goat Latin by transforming each word: 1. If the word starts with a vowel (a, e, i, o, u, in either case), append "ma". 2. Otherwise, move the first letter to the end of the word, then append "ma". 3. Then append the letter 'a' repeated k times, where k is the word's 1-based position in the sentence. Return the transformed words joined by single spaces. Keep every letter's original case.

Examples

Input: sentence = "I speak Goat Latin"
Output: "Imaa peaksmaaa oatGmaaaa atinLmaaaaa"
"I" starts with a vowel; the other words move their first letter to the end.
Input: sentence = "The quick brown fox"
Output: "heTmaa uickqmaaa rownbmaaaa oxfmaaaaa"
"The" becomes "heT" + "ma" + "a"; the 4th word "fox" becomes "oxf" + "ma" + "aaaa".

Constraints

  • 1 <= sentence.length <= 150
  • `sentence` consists of English letters and spaces
  • `sentence` has no leading or trailing spaces
  • Words are separated by exactly one space

What the interviewer grades

A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.

More simulation problems