diff --git a/mergeKLists.java b/mergeKLists.java new file mode 100644 index 0000000..251981e --- /dev/null +++ b/mergeKLists.java @@ -0,0 +1,43 @@ +/** + * Definition for singly-linked list. + * public class ListNode { + * int val; + * ListNode next; + * ListNode() {} + * ListNode(int val) { this.val = val; } + * ListNode(int val, ListNode next) { this.val = val; this.next = next; } + * } + */ +class Solution { + public ListNode mergeKLists(ListNode[] lists) { + + //ListNode a = new ListNode(); + if(lists.length==0){ + return null; + } + + for(int k=1; k