1678. Goal Parser Interpretation

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1678

class Solution:
    def interpret(self, command: str) -> str:
        res = []
        for i, c in enumerate(command):
            if c == 'G':
                res.append(c)
            elif c == '(':
                res.append('o' if command[i + 1] == ')' else 'al')
        return ''.join(res)