Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
850. Rectangle Area II
Bookmark
Inclusion-Exclusion
Coordinate Compression
Sweep Line
Input
Standard
Overlapping
Non-overlapping
Complex
Custom
rectangles
=
[[0,0,2,2],[1,0,2,3],[1,0,3,1]]
-1
0
1
2
3
4
-1
0
1
2
3
4
R0
R1
R2
total area
0
-1
0
1
2
3
4
-1
0
1
2
3
4
R0
R1
R2
total area
0
-1
0
1
2
3
4
-1
0
1
2
3
4
R0
R1
R2
total area
0
-1
0
1
2
3
4
-1
0
1
2
3
4
R0
R1
R2
x=0
cnt (y-strip coverage)
0
[0,1)
0
[1,2)
0
[2,3)
total area
0
-1
0
1
2
3
4
-1
0
1
2
3
4
R0
R1
R2
x=1
cnt (y-strip coverage)
1
[0,1)
1
[1,2)
0
[2,3)
total area
0
-1
0
1
2
3
4
-1
0
1
2
3
4
R0
R1
R2
x=1
cnt (y-strip coverage)
2
[0,1)
2
[1,2)
1
[2,3)
total area
2
-1
0
1
2
3
4
-1
0
1
2
3
4
R0
R1
R2
x=1
cnt (y-strip coverage)
3
[0,1)
2
[1,2)
1
[2,3)
total area
2
-1
0
1
2
3
4
-1
0
1
2
3
4
R0
R1
R2
x=2
cnt (y-strip coverage)
3
[0,1)
2
[1,2)
1
[2,3)
slice: 3 x 1 = 3
total area
5
-1
0
1
2
3
4
-1
0
1
2
3
4
R0
R1
R2
x=2
cnt (y-strip coverage)
2
[0,1)
1
[1,2)
1
[2,3)
total area
5
-1
0
1
2
3
4
-1
0
1
2
3
4
R0
R1
R2
x=3
cnt (y-strip coverage)
1
[0,1)
0
[1,2)
0
[2,3)
total area
5
-1
0
1
2
3
4
-1
0
1
2
3
4
R0
R1
R2
cnt (y-strip coverage)
0
[0,1)
0
[1,2)
0
[2,3)
total area
6
algo
master
.
io
Step:
Find the total area covered by the union of axis-aligned rectangles
0 / 23
Input
Standard
Overlapping
Non-overlapping
Complex
Custom
rectangles
=
[[0,0,2,2],[1,0,2,3],[1,0,3,1]]
0 / 23
algo
master
.
io
Step:
Find the total area covered by the union of axis-aligned rectangles