Download Range Addition.py
class Solution(object): def getModifiedArray(self, length, updates): """ :type length: int :type updates: List[List[int]] :rtype: List[int] """ res =  * length # interval problem for t in updates: start, end, val = t res[start] += val if end < length - 1: res[end + 1] -= val # Cumulative sums for i in range(1, length): res[i] = res[i] + res[i - 1] return res
Leetcode 370 Range Addition problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.
Feedback is the most important part of any website.
If you have any query, suggestion or feedback, Please feel free to contact us.