Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Segment Tree with Lazy Propagation
Bookmark
Input
Standard
Small
Full Range Query
Update All
Custom
arr
=
[1, 6, 8, 10, 12, 11]
,
updateL
=
1
,
updateR
=
4
,
updateVal
=
3
,
queryL
=
2
,
queryR
=
5
1
0
3
1
5
2
7
3
9
4
11
5
1
0
3
1
5
2
7
3
9
4
11
5
1
0
3
1
5
2
7
3
9
4
11
5
0
[0,5]
0
[0,2]
0
[0,1]
1
[0]
3
[1]
1
0
3
1
5
2
7
3
9
4
11
5
0
[0,5]
9
[0,2]
4
[0,1]
1
[0]
3
[1]
5
[2]
0
[3,5]
1
0
3
1
5
2
7
3
9
4
11
5
0
[0,5]
9
[0,2]
4
[0,1]
1
[0]
3
[1]
5
[2]
0
[3,5]
16
[3,4]
7
[3]
9
[4]
11
[5]
update
1
0
3
1
5
2
7
3
9
4
11
5
36
[0,5]
9
[0,2]
4
[0,1]
1
[0]
3
[1]
5
[2]
27
[3,5]
16
[3,4]
7
[3]
9
[4]
11
[5]
update
1
0
3
1
5
2
7
3
9
4
11
5
36
[0,5]
9
[0,2]
4
[0,1]
1
[0]
6
[1]
+3
5
[2]
27
[3,5]
16
[3,4]
7
[3]
9
[4]
11
[5]
update
1
0
3
1
5
2
7
3
9
4
11
5
36
[0,5]
15
[0,2]
7
[0,1]
1
[0]
6
[1]
+3
8
[2]
+3
27
[3,5]
16
[3,4]
7
[3]
9
[4]
11
[5]
update
1
0
6
1
8
2
10
3
12
4
11
5
48
[0,5]
15
[0,2]
7
[0,1]
1
[0]
6
[1]
+3
8
[2]
+3
33
[3,5]
22
[3,4]
+3
7
[3]
9
[4]
11
[5]
query
1
0
6
1
8
2
10
3
12
4
11
5
48
[0,5]
15
[0,2]
7
[0,1]
1
[0]
6
[1]
+3
8
[2]
+3
33
[3,5]
22
[3,4]
+3
7
[3]
9
[4]
11
[5]
1
0
6
1
8
2
10
3
12
4
11
5
48
[0,5]
15
[0,2]
7
[0,1]
1
[0]
6
[1]
+3
8
[2]
+3
33
[3,5]
22
[3,4]
+3
7
[3]
9
[4]
11
[5]
algo
master
.
io
Step:
Start: Build a segment tree from array [1, 3, 5, 7, 9, 11], then perform range update and range query with lazy propagation.
0 / 41
Input
Standard
Small
Full Range Query
Update All
Custom
arr
=
[1, 6, 8, 10, 12, 11]
,
updateL
=
1
,
updateR
=
4
,
updateVal
=
3
,
queryL
=
2
,
queryR
=
5
0 / 41
algo
master
.
io
Step:
Start: Build a segment tree from array [1, 3, 5, 7, 9, 11], then perform range update and range query with lazy propagation.