Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
Merge k Sorted Lists
Bookmark
Input
Example 1
Example 2
Example 3
Custom
lists
=
[[1,4,5],[1,3,4],[2,6]]
input lists
min-heap · size
0
L0
∅
1
4
5
L1
∅
1
3
4
L2
∅
2
6
out
the heap always holds one front node per list; pop the smallest, repeat
algo
master
.
io
Step:
Merge k sorted lists by always taking the smallest available head
0 / 30
Input
Example 1
Example 2
Example 3
Custom
lists
=
[[1,4,5],[1,3,4],[2,6]]
0 / 30
input lists
min-heap · size
0
L0
∅
1
4
5
L1
∅
1
3
4
L2
∅
2
6
out
the heap always holds one front node per list; pop the smallest, repeat
algo
master
.
io
Step:
Merge k sorted lists by always taking the smallest available head