Learn
Practice
Newsletter
Resources
Mobile
New
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Minimum Interval to Include Each Query
Bookmark
Input
Standard
Simple
No match
Custom
intervals
=
[[1,4],[2,4],[3,6],[4,4]]
,
queries
=
[2, 3, 4, 5]
[1,4]
[2,4]
[3,6]
[4,4]
1
2
3
4
5
6
heap (size,end)
queries
2
3
4
5
result
?
0
?
1
?
2
?
3
[1,4]
[2,4]
[3,6]
[4,4]
1
2
3
4
5
6
heap (size,end)
queries
2
3
4
5
result
?
0
?
1
?
2
?
3
[1,4]
[2,4]
[3,6]
[4,4]
1
2
3
4
5
6
heap (size,end)
(empty)
queries
2
3
4
5
result
?
0
?
1
?
2
?
3
heap = [ ], i = 0
[1,4]
[2,4]
[3,6]
[4,4]
q
1
2
3
4
5
6
heap (size,end)
(4,4)
queries
2
3
4
5
result
?
0
?
1
?
2
?
3
left = 1 <= q = 2 : push (4,4)
[1,4]
[2,4]
[3,6]
[4,4]
q
1
2
3
4
5
6
heap (size,end)
(4,4)
(3,4)
queries
2
3
4
5
result
?
0
?
1
?
2
?
3
q = 3
[1,4]
[2,4]
[3,6]
[4,4]
q
1
2
3
4
5
6
heap (size,end)
(4,4)
(3,4)
min
(4,6)
queries
2
3
4
5
result
?
0
?
1
?
2
?
3
answer = min size = 3
[1,4]
[2,4]
[3,6]
[4,4]
q
1
2
3
4
5
6
heap (size,end)
(4,4)
(3,4)
(4,6)
(1,4)
min
queries
2
3
4
5
result
?
0
?
1
?
2
?
3
answer = min size = 1
[1,4]
[2,4]
[3,6]
[4,4]
q
1
2
3
4
5
6
heap (size,end)
(4,4)
(3,4)
(4,6)
(1,4)
queries
2
3
4
5
result
?
0
?
1
?
2
?
3
end = 4 < q = 5 : discard (1,4)
[1,4]
[2,4]
[3,6]
[4,4]
q
1
2
3
4
5
6
heap (size,end)
(4,6)
min
queries
2
3
4
5
result
?
0
?
1
?
2
?
3
answer = min size = 4
[1,4]
[2,4]
[3,6]
[4,4]
1
2
3
4
5
6
heap (size,end)
(4,6)
queries
2
3
4
5
result
3
0
3
1
?
2
?
3
result[1] = map[3] = 3
[1,4]
[2,4]
[3,6]
[4,4]
1
2
3
4
5
6
heap (size,end)
(4,6)
queries
2
3
4
5
result
3
0
3
1
1
2
4
3
result: [3, 3, 1, 4]
algo
master
.
io
Step:
Find the smallest interval containing each query
0 / 23
Input
Standard
Simple
No match
Custom
intervals
=
[[1,4],[2,4],[3,6],[4,4]]
,
queries
=
[2, 3, 4, 5]
0 / 23
algo
master
.
io
Step:
Find the smallest interval containing each query