You are viewing a single comment's thread. Return to all comments →
tricky. Not explained very well.. KEY : prefix sum algorthim
arr = [0] * (n+2) for i in range(len(queries)): a = queries[i][0] b = queries[i][1] k = queries[i][2] arr[ a ] += k arr[ b +1] -= k max_value = 0 current = 0 for val in arr: current += val max_value = max(max_value, current) return (max_value)
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
tricky. Not explained very well.. KEY : prefix sum algorthim