Python Simple Solution

  • 0
    class Solution(object):
        def getModifiedArray(self, length, updates):
            nums = [0 for _ in range(length)]
            for update in updates:
                i, j, k = update
                nums[i] += k
                if j+1 < length:
                    nums[j+1] -= k
            for i in range(1,length):
                nums[i] += nums[i-1]
            return nums

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.