Kotlin Leetcode - 1929. Concatenation of Array
題目連接:https://leetcode.com/problems/concatenation-of-array/
class Solution {
fun getConcatenation(nums: IntArray): IntArray {
}
}
解題思路
這一題考的是陣列的基本處理
在其他語言內
會需要建立新陣列
並針對元素進行一系列操作
在 Kotlin 內可以用更簡單的方式實作
Kotlin 參考解答
單一表達式內完成的方式如下
class Solution {
fun getConcatenation(nums: IntArray) =
nums + nums
}
回到 leetcode 列表