1678. Goal Parser Interpretation

Обновлено: 2024-03-12
1 мин
[]

Содержание

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)