Code Room
CodingHard
Question
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.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.