Skip to content

Commit 7267348

Browse files
authored
Update MergeKSortedLists.java
1 parent d484763 commit 7267348

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

LeetCode/MergeKSortedLists.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//Solution to https://leetcode.com/problems/merge-k-sorted-lists/
22
//Approach: We use the logic behind merging two sorted lists to merge k number of lists in sorted order.
3-
//Here two lists are taken at a time and merged. The process is repeated until the last one list in the array.
3+
//Pair up k lists and merge each pair.
4+
//After the first pairing, k lists are merged into k/2 lists with average 2N/k length, then k/4, k/8 and so on.
5+
//This is repeated until we get the final sorted linked list.
46

57
class Solution {
68
public ListNode mergeTwoLists(ListNode l1, ListNode l2) {

0 commit comments

Comments
 (0)