Goat Latin LeetCode solution in C++
1class Solution {2public:3string toGoatLatin(string sentence) {4sentence += ' ';5vector<string> Words;6string TEMP, SOL, A = "a";7for (int i = 0; i < sentence.size(); ++i) {8if (sentence[i] == ' ') {9Words.push_back(TEMP);10TEMP = "";11} else12TEMP += sentence[i];13}14for (string V : Words) {15char TMP = tolower(V[0]);16if (TMP == 'a' || TMP == 'e' || TMP == 'i' || TMP == 'o' || TMP == 'u')17V += "ma";18else {19TMP = V[0];20V.erase(0, 1);21V += TMP;22V += "ma";23}24V += A;25A += 'a';26SOL += V + ' ';27}28SOL.erase(SOL.size() - 1, 1);29return SOL;30}31};