Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Smallest Range Covering Elements from K Lists
Bookmark
Check All Pairs
Sliding Window
Min-Heap
Input
Standard
Identical
Evenly spaced
Small
Custom
nums
=
[4,10,15,24,26], [0,9,12,20], [5,18,22,30]
value axis · window must cover every list
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
sort every value, then expand from each start until all k lists are covered
value axis · window must cover every list
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
sort every value, then expand from each start until all k lists are covered
value axis · window must cover every list
covers
3
/ 3 · width
5
[0, 5]
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
best
[0, 30] · w=30
[0, 5]
covers every list · width
5
value axis · window must cover every list
covers
1
/ 3 · width
0
[5, 5]
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
best
[0, 5] · w=5
take in
5
· covers
1
/ 3 lists
value axis · window must cover every list
covers
2
/ 3 · width
3
[9, 12]
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
best
[0, 5] · w=5
take in
12
· covers
2
/ 3 lists
value axis · window must cover every list
covers
3
/ 3 · width
8
[10, 18]
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
best
[0, 5] · w=5
take in
18
· covers
3
/ 3 lists
value axis · window must cover every list
covers
3
/ 3 · width
6
[12, 18]
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
best
[0, 5] · w=5
width
6
not smaller than best
5
value axis · window must cover every list
covers
2
/ 3 · width
2
[18, 20]
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
best
[0, 5] · w=5
take in
20
· covers
2
/ 3 lists
value axis · window must cover every list
covers
3
/ 3 · width
4
[20, 24]
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
best
[0, 5] · w=5
take in
24
· covers
3
/ 3 lists
value axis · window must cover every list
covers
1
/ 3 · width
0
[24, 24]
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
best
[20, 24] · w=4
take in
24
· covers
1
/ 3 lists
value axis · window must cover every list
covers
3
/ 3 · width
4
[20, 24]
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
best
[20, 24] · w=4
smallest range = [20, 24]
algo
master
.
io
Step:
Find the smallest range [lo, hi] that contains at least one number from every list
0 / 76
Input
Standard
Identical
Evenly spaced
Small
Custom
nums
=
[4,10,15,24,26], [0,9,12,20], [5,18,22,30]
0 / 76
algo
master
.
io
Step:
Find the smallest range [lo, hi] that contains at least one number from every list