Mutable range sum queries

Write codeMedium30 min

Your task

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.

Examples

segtree_sum_ops(nums: list[int], ops: list[list]) -> list[int]
Example 1
Inputsegtree_sum_ops([1, 3, 5, 7, 9, 11], [["q", 1, 3], ["u", 1, 10], ["q", 1, 3]])
Output[15, 22]