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
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
slide a window covering one value per list; keep the narrowest one
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
slide a window covering one value per list; keep the narrowest one
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
push
L2 = 5
· max =
5
value axis · window must cover every list
width
5
[0, 5]
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
best
[0, 5] · w=5
width
5
not smaller than best
5
value axis · window must cover every list
width
5
[5, 10]
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
best
[0, 5] · w=5
advance
L0
→ push
10
· max =
10
value axis · window must cover every list
width
9
[9, 18]
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
best
[0, 5] · w=5
pop min =
9
(L1) · window
[9, 18]
value axis · window must cover every list
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
pop min =
10
(L0) · window
[10, 18]
value axis · window must cover every list
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
width
6
[18, 24]
L0
4
10
15
24
26
L1
0
9
12
20
L2
5
18
22
30
0
30
best
[0, 5] · w=5
advance
L0
→ push
24
· max =
24
value axis · window must cover every list
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
advance
L2
→ push
22
· max =
24
value axis · window must cover every list
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 / 33
Input
Standard
Identical
Evenly spaced
Small
Custom
nums
=
[4,10,15,24,26], [0,9,12,20], [5,18,22,30]
0 / 33
algo
master
.
io
Step:
Find the smallest range [lo, hi] that contains at least one number from every list