Skip to content

Practice Goal Parser Interpretation

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1678
LeetCode Problem

Goal Parser Interpretation

Problem Statement

You own a Goal Parser that can interpret a string command. The command consists of an alphabet of "G", "()" and/or "(al)" in some order. The Goal Parser will interpret "G" as the string "G", "()" as the string "o", and "(al)" as the string "al". The interpreted strings are then concatenated in the original order. Given the string command, return the Goal Parser's interpretation of command.

Source: Goal Parser Interpretation on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

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

# Example 2

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

# Example 3

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

Constraints

1 <= command.length <= 100
command consists of "G", "()", and/or "(al)" in some order.

Related LeetCode Problems

Practice more problems similar to Goal Parser Interpretation.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.