# LeetCode 1678. Goal Parser Interpretation

## Description

https://leetcode.com/problems/goal-parser-interpretation/

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`.

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"
```

Constraints:

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

## Explanation

Specifically deal with “(“.

## Python Solution

``````class Solution:
def interpret(self, command: str) -> str:
result = ""

i = 0
while i < len(command):
c = command[i]

if c == '(':
i += 1
if i < len(command) and command[i] == ')':
result += 'o'
else:
if c != ')':
result += c
i += 1

return result``````
• Time Complexity: O(N)
• Space Complexity: O(N)
{"ft_lang_label":"__label__en","ft_lang_prob":0.7215694,"math_prob":0.8577003,"size":1219,"snap":"2023-40-2023-50","text_gpt3_token_len":346,"char_repetition_ratio":0.15144032,"word_repetition_ratio":0.0,"special_character_ratio":0.32731748,"punctuation_ratio":0.17372881,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9961162,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-11-29T14:56:16Z\",\"WARC-Record-ID\":\"<urn:uuid:34088975-61b8-4c29-a2a9-0b407cbc3b12>\",\"Content-Length\":\"53192\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:56d01ddc-b1c2-4465-a2b1-1af40612162c>\",\"WARC-Concurrent-To\":\"<urn:uuid:3f63f0e1-7a68-4b3d-a983-25ce428b4b77>\",\"WARC-IP-Address\":\"72.44.43.28\",\"WARC-Target-URI\":\"https://www.goodtecher.com/leetcode-1678-goal-parser-interpretation/\",\"WARC-Payload-Digest\":\"sha1:R7OW3NOKT5FWAGAZBC7GYGGLG5C5SW3M\",\"WARC-Block-Digest\":\"sha1:GONNXQIPSQGPVARWRQTOAJ3BLUB3YYHJ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100112.41_warc_CC-MAIN-20231129141108-20231129171108-00247.warc.gz\"}"}