Maximum subarray with updates
Maintain an integer array under point assignments and answer maximum-subarray queries. Process operations: ["set", i, v] assigns arr[i] = v, and ["max"] returns the maximum sum of any NON-EMPTY contiguous subarray of the current array. Return the list of answers to "max" operations in order. Each operation must run in O(log n).
Implement
max_subarray_with_updates(arr: list[int], ops: list[list]) → list[int]Examples
in
[[1,-2,3,4,-1],[["max"],["set",1,5],["max"],["set",3,-10],["max"]]]out[7,13,9]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 45 min
solution.py
InputExpectedGot
[[1,-2,3,4,-1],[["max"],["set",1,5],["max"],["set",3,-10],["max"]]][7,13,9]not run yetsample