Files
LeetCode-Go/leetcode/1678.Goal-Parser-Interpretation/1678. Goal Parser Interpretation.go
2020-12-15 13:15:14 +08:00

23 lines
328 B
Go

package leetcode
func interpret(command string) string {
if command == "" {
return ""
}
res := ""
for i := 0; i < len(command); i++ {
if command[i] == 'G' {
res += "G"
} else {
if command[i] == '(' && command[i+1] == 'a' {
res += "al"
i += 3
} else {
res += "o"
i++
}
}
}
return res
}