#1678

Goal Parser Interpretation

newbie · 100 · lc easy +12 · verified · 88% accepted · 1,673 likes · top 99%

Description

A Goal Parser reads a command string and translates it: "G" becomes "G", "()" becomes "o", and "(al)" becomes "al". All translated parts are concatenated in order. Return the parsed result.

Example 1:

Input: command = "G()(al)"
Output: "Goal"
Explanation: The Goal Parser interprets the command as follows:
G -> G
() -> o
(al) -> al
The final concatenated result is "Goal".

Example 2:

Input: command = "G()()()()(al)"
Output: "Gooooal"

Example 3:

Input: command = "(al)G(al)()()G"
Output: "alGalooG"

Code

1
2
3