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)}");

posted @ 2022-04-30 23:44  wesson2019  阅读(20)  评论(0编辑  收藏  举报