Code RoomSegment tree range max
MediumPrep Room Coding #1118

Segment tree range max

CodingAlgorithms & data structuresMid–Senior~30 min

Build an iterative (bottom-up) segment tree over an integer array supporting point updates and range-max queries. Process operations: ["set", pos, v] sets arr[pos] = v; ["query", l, r] returns the maximum over the inclusive range [l, r]. Return the list of query answers in order. Use the array-backed iterative segment tree (size padded to a power of two) so each operation is O(log n) with low constant factors.

Implement
range_max_point_update(arr: list[int], ops: list) → list[int]
Examples
in[[1,3,2,7,9,11],[["query",0,3],["set",2,15],["query",0,3],["query",4,5]]]out[7,15,11]
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 30 min
InputExpectedGot
[[1,3,2,7,9,11],[["query",0,3],["set",2,15],["query",0,3],["query",4,5]]][7,15,11]not run yetsample