Skip to content

Commit d08edd2

Browse files
committed
Goal Parser Interpretation
1 parent a672469 commit d08edd2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// https://leetcode.com/problems/goal-parser-interpretation/
2+
3+
class Solution
4+
{
5+
public:
6+
string interpret(string command)
7+
{
8+
string result = "";
9+
int stringLength = command.size();
10+
11+
for (int i = 0; i < stringLength; i++)
12+
{
13+
if (command[i] == 'G')
14+
{
15+
result += "G";
16+
}
17+
else if (command[i] == '(' && command[i + 1] == ')')
18+
{
19+
result += "o";
20+
i++;
21+
}
22+
else
23+
{
24+
result += "al";
25+
i += 3;
26+
}
27+
}
28+
29+
return result;
30+
}
31+
};

0 commit comments

Comments
 (0)