Recca Chao 的 gitHub page

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

View on GitHub

Kotlin Leetcode - 1929. Concatenation of Array

題目連接

class Solution {
    fun getConcatenation(nums: IntArray): IntArray {
        
    }
}

解題思路

這一題考的是陣列的基本處理

在其他語言內

會需要建立新陣列

並針對元素進行一系列操作

在 Kotlin 內可以用更簡單的方式實作

Kotlin 參考解答

點擊展開解答

單一表達式內完成的方式如下

class Solution {
    fun getConcatenation(nums: IntArray) = 
        nums + nums
}

回到 leetcode 列表