AlgoMaster Logo

Range Sum Query - Mutable

nums=[1, 3, 5, 7, 9, 11],operations=[{"type":"update","index":2,"val":10},{"type":"sumRange","left":1,"right":4}]
0 / 29
NumArray([1, 3, 5, 7, 9, 11])update(2, 10)sumRange(1, 4) = ?nums000000012345bit000000123456each bit[i] stores the sum of a power-of-two block ending at i
algomaster.io
Step:Fenwick tree: each cell stores a partial sum.