Algorithms/- LeetCode

LeetCode - 1480. Running Sum of 1d Array [Kotlin]

자굿 2022. 8. 2. 10:30
 

Running Sum of 1d Array - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

 

정답 ( Solution )

 

class Solution {
    fun runningSum(nums: IntArray): IntArray {
        for(i in 1 until nums.size){
            nums[i] += nums[i-1]
        }
        return nums
    }
}
반응형