straightforward python solution

  • 0
    class Solution(object):
        def getModifiedArray(self, length, updates):
            res = [0] * length
            for s, e, val in updates:
                res[s] += val
                if e < length-1:
                    res[e+1] -= val
            for i in range(1, length):
                res[i] += res[i-1]
            return res

Log in to reply

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