You are viewing a single comment's thread. Return to all comments →
Python 3:
def arrayManipulation(n, queries): l = [] for a, b, k in queries: l.append((a-1, k)) l.append((b, -k)) l.sort() curr_sum = 0 best = -1 curr_index = 0 for idx, val in l: if idx != curr_index: best = max(best, curr_sum) curr_index = idx curr_sum += val return best
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 →
Python 3: