Goal Parser Interpretation LeetCode solution in C++
1class Solution {2public:3string interpret(string command) {4string s = "", str;5for (char ch : command) {6s += ch;7if (s == "G") {8str += "G";9s = "";10} else if (s == "()") {11str += "o";12s = "";13} else if (s == "(al)") {14str += "al";15s = "";16}17}18return str;19}20};