307. Range Sum Query-Mutable
查询数组任意区间内元素的和,数组里的数都是可变的。
int[] nums = { 1, 3, 5 };
var tree = new SegmentTree();
tree.Init(nums, OperSum);
Console.WriteLine($"RangeSum(0,2) -> {tree.QueryLazy(0, 2)}");
Console.WriteLine("update(1,20)");
tree.Update(1, 20);
Console.WriteLine($"RangeSum(0,2) -> {tree.QueryLazy(0, 2)}");