Goal Parser Interpretation LeetCode solution in C++

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

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0