Skip to content

Commit

Permalink
Update merge-k-sorted-lists/dev-jonghoonpark.md
Browse files Browse the repository at this point in the history
Co-authored-by: Dale Seo <[email protected]>
  • Loading branch information
dev-jonghoonpark and DaleSeo authored Aug 3, 2024
1 parent 0d36d5d commit 3abcdb7
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions merge-k-sorted-lists/dev-jonghoonpark.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,18 @@ class Solution {
ListNode current = mergedList;

while (true) {
boolean done = true;
int minIndex = 0;
int minIndex = -1;
int currentMin = Integer.MAX_VALUE;

for (int i = 0; i < lists.length; i++) {
ListNode node = lists[i];
if (node == null) {
continue;
}

if (node.val < currentMin) {
if (node != null && node.val < currentMin) {
minIndex = i;
currentMin = node.val;
done = false;
}
}

if (done) {
if (minIndex == -1) {
break;
}

Expand Down

0 comments on commit 3abcdb7

Please sign in to comment.