Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
Range Sum Query - Mutable
Bookmark
Input
Standard
Simple
Single Update
Custom
nums
=
[1, 3, 5, 7, 9, 11]
,
operations
=
[{"type":"update","index":2,"val":10},{"type":"sumRange","left":1,"right":4}]
NumArray([1, 3, 5, 7, 9, 11])
update(2, 10)
sumRange(1, 4)
=
?
nums
0
0
0
0
0
0
0
1
2
3
4
5
bit
0
0
0
0
0
0
1
2
3
4
5
6
each bit[i] stores the sum of a power-of-two block ending at i
algo
master
.
io
Step:
Fenwick tree: each cell stores a partial sum.
0 / 29
Input
Standard
Simple
Single Update
Custom
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)
=
?
nums
0
0
0
0
0
0
0
1
2
3
4
5
bit
0
0
0
0
0
0
1
2
3
4
5
6
each bit[i] stores the sum of a power-of-two block ending at i
algo
master
.
io
Step:
Fenwick tree: each cell stores a partial sum.