Kotlin Leetcode - 1480. Running Sum of 1d Array
class Solution {
fun runningSum(nums: IntArray): IntArray {
}
}
解題思路
這一題解法非常單純
可以直接以迴圈實作
Kotlin 參考解答
class Solution {
fun runningSum(nums: IntArray): IntArray {
val result = IntArray(nums.size)
result[0] = nums[0]
for (i in 1 until nums.size) {
result[i] = nums[i] + result[i - 1]
}
return result
}
}
回到 leetcode 列表