Leetcode Note: Go - Goal Parser Interpretation
Goal Parser Interpretation - LeetCode
https://leetcode.com/problems/goal-parser-interpretation/
- Go 言語で取り組んだメモ
回答
Go golang clean solution - Goal Parser Interpretation - LeetCode
https://leetcode.com/problems/goal-parser-interpretation/solutions/964059/go-golang-clean-solution/
func interpret(command string) string {
ans, i, n := "", 0, len(command)
for i < n {
if command[i:i+1] == "G" {
ans += "G"; i++
} else if command[i:i+2] == "()" {
ans += "o"; i += 2
} else {
ans += "al"; i += 4
}
}
return ans
}