Goal Parser Interpretation

A Goal Parser reads a `command` string made only of the pieces `"G"`, `"()"` and `"(al)"`, in some order. It reads `"G"` as `"G"`, `"()"` as `"o"` and `"(al)"` as `"al"`, then joins the decoded pieces in their original order. Return the Goal Parser's interpretation of `command`.

30:00

Goal Parser Interpretation
easy
Free written solution
Topics
Companies

A Goal Parser reads a command string made only of the pieces "G", "()" and "(al)", in some order. It reads "G" as "G", "()" as "o" and "(al)" as "al", then joins the decoded pieces in their original order. Return the Goal Parser's interpretation of command.

Example 1:
Input: {"command":"G()(al)"}
Output: Goal
Constraints:
  • 1 <= command.length <= 100

  • command consists of "G", "()" and/or "(al)" in some order.

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"command":"G()(al)"}

Put the read head at i = 0. Each step looks at command[i]: a 'G' is one character, a '(' starts either "()" or "(al)".

"G"

→

"G"

i+=1

"()"

→

"o"

i+=2

"(al)"

→

"al"

i+=4

command, cut into tokens

i = 0 / 7

i=0

G

1

(

2

)

3

(

4

a

5

l

6

)

out (0 chars)

_
Variables
VariableValue
i0
out""
DepthFunction Call
Stack empty
0/7