You are viewing a single comment's thread. Return to all comments →
Only consider the query indices.
def arrayManipulation(n, queries): # Write your code here sweepline = {} # O(N) for (start, end, value) in queries: sweepline[start] = sweepline.get(start, 0) + value sweepline[end + 1] = sweepline.get(end + 1, 0) - value maxnum = float("-inf") curr = 0 for index in sorted(sweepline.keys()): curr += sweepline[index] maxnum = max(maxnum, curr) return maxnum
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 →
Only consider the query indices.