Answers for "Goal Parser Interpretation leetcode in c++"

C++
0

Goal Parser Interpretation leetcode in c++

class Solution {
public:
    string interpret(string command) {
        string s;
        for(int i=0;i<command.length();i++)
        {
            if(command[i]=='G')
            {
                s+="G";
            }
            if(command[i]=='('&&command[i+1]==')')
            {
                s+="o";
            }
            if(command[i]=='('&&command[i+1]=='a')
            {
                s+="al";
            }
        }
        return s;
    }
};
Posted by: Guest on March-08-2022

Browse Popular Code Answers by Language