Recca Chao 的 gitHub page

推廣網站開發,包含 Laravel 和 Kotlin 後端撰寫、自動化測試、讀書心得等。Taiwan Kotlin User Group 管理員。

View on GitHub

Kotlin Leetcode - 1678. Goal Parser Interpretation

題目連接

class Solution {
    fun interpret(command: String): String {

    }
}

解題思路

這一題考的是對字串的處理

邏輯非常單純

可以直接用字串的 replace() 處理

Kotlin 參考解答

replace() 處理的作法如下

class Solution {
    fun interpret(command: String) = command.replace("()","o").replace("(al)","al")
}

回到 leetcode 列表