14: Merge sorted lists

Given an array of sorted linked lists, merge all lists into one sorted linked list

 

Example 1

Input:  lists =
                [
                    1 -> 2,
                    2 -> 3,
                    1 -> 4
                ]


Output: 1 -> 1 -> 2 -> 2 -> 3 -> 4

Example 2

Input:  lists =
                [
                    1 -> 2 -> 3 -> 10,
                    2 -> 3,
                    1 -> 4
                ]


Output: 1 -> 1 -> 2 -> 2 -> 3 -> 3 -> 4 -> 10