Mutable range sum queries
Implement a mutable range-sum structure. Given an initial array `nums` and a list of operations `ops`, process them in order: `["u", i, val]` sets index i to val (point assignment), and `["q", l, r]` asks for the inclusive sum over [l, r]. Return the list of answers to the query operations, in order. Both updates and queries must run in O(log n). `0 <= len(nums) <= 100000`, `len(ops) <= 100000`.
Implement
segtree_sum_ops(nums: list[int], ops: list[list]) → list[int]Examples
in
[[1,3,5,7,9,11],[["q",1,3],["u",1,10],["q",1,3]]]out[15,22]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
solution.py
InputExpectedGot
[[1,3,5,7,9,11],[["q",1,3],["u",1,10],["q",1,3]]][15,22]not run yetsample