Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- knakul853
- **/
- class Solution {
- public:
- string toGoatLatin(string S) {
- stringstream in(S), out;
- string word, vowels("aeiouAEIOU");
- string a;
- while( in >> word )
- {
- a.push_back('a');
- if( vowels.find(word[0])!=string::npos) // vowels
- {
- out <<" "<< word<<"ma"<<a;
- }
- else{
- out <<" "<<word.substr(1)<<word[0]<<"ma"<<a;
- }
- }
- return out.str().substr(1);
- }
- };
Add Comment
Please, Sign In to add comment