186. Goal Parser Interpretation

EasyStringString

You own a Goal Parser that can interpret a string command.

The command consists of: 'G', '()', '(al)'.

- 'G' → interpreted as the string 'G'
- '()' → interpreted as the string 'o'
- '(al)' → interpreted as the string 'al'

Return the Goal Parser's interpretation of the command string.

Input: A string command consisting only of 'G', '()', and '(al)'.

Output: A string — the interpreted result.

Examples

Example 1
Input: G()(al)
Output: Goal
Explanation: G→G, ()→o, (al)→al → 'Goal'.
Example 2
Input: G()()
Output: Goo
Explanation: G→G, ()→o, ()→o → 'Goo'.
Example 3
Input: (al)G(al)()
Output: alGalo
Explanation: (al)→al, G→G, (al)→al, ()→o → 'alGalo'.

Constraints

Asked by

Google
Solve this problem in the editor →