Goal Parser Interpretation

EasyString

Description

You own a Goal Parser that can interpret a string command. The command consists of "G", "()" and "(al)". Parse to return "G", "o", and "al" respectively.

Examples

Input:command = "G()(al)"
Output:"Goal"
Explanation:

Parse each token: 'G' → 'G', '()' → 'o', '(al)' → 'al'. Concatenated result is 'Goal'.

Input:command = "(al)"
Output:"al"
Explanation:

The string contains only (al) which maps to 'al' according to the parsing rules.

Input:command = "G()G(al)G"
Output:"GoGalG"
Explanation:

G stays as G, () becomes o, G stays as G, (al) becomes al, and G stays as G, resulting in GoGalG.

Constraints

  • 1 ≤ command.length ≤ 100

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!