Day 39
Date: November 6, 2022 9:13 AM
LinkedIn: https://leetcode.cn/problems/goal-parser-interpretation/description/
Title: 设计 Goal 解析器
class Solution:
def interpret(self, command: str) -> str:
s=''# 初始字符串
n=len(command)
i=0
while i<n:
if command[i]=='G':# G 解释为G
s+='G'
i+=1
elif command[i]=='(' and command[i+1]==')': # 遇到()解释为o
s+='o'
i+=2
else: # 其他就只剩下(al) 解释为al
s+='al'
i+=4
return s