We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fbdac2d commit 541b7aaCopy full SHA for 541b7aa
_posts/2024-02-19-leetcode-23.md
@@ -215,24 +215,18 @@ class Solution {
215
ListNode current = mergedList;
216
217
while (true) {
218
- boolean done = true;
219
- int minIndex = 0;
+ int minIndex = -1;
220
int currentMin = Integer.MAX_VALUE;
221
222
for (int i = 0; i < lists.length; i++) {
223
ListNode node = lists[i];
224
- if (node == null) {
225
- continue;
226
- }
227
-
228
- if (node.val < currentMin) {
+ if (node != null && node.val < currentMin) {
229
minIndex = i;
230
currentMin = node.val;
231
- done = false;
232
}
233
234
235
- if (done) {
+ if (minIndex == -1) {
236
break;
237
238
0 commit comments