Skip to content

Commit

Permalink
Fixing wrong var name
Browse files Browse the repository at this point in the history
  • Loading branch information
teivah committed Feb 2, 2020
1 parent 1620f67 commit c1466bb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions heap.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,16 @@ public static List<Integer> findKLargestNumbers(int[] nums, int k) {
}
}

// Remove all elements from the heap.
List<Integer> largest = new ArrayList<>(minHeap.size());
return toList(minHeap);
}

public static List<Integer> toList(PriorityQueue<Integer> minHeap) {
List<Integer> list = new ArrayList<>(minHeap.size());
while (!minHeap.isEmpty()) {
largest.add(heap.poll());
list.add(minHeap.poll());
}
return largest;

return list;
}
```

Expand Down

0 comments on commit c1466bb

Please sign in to comment.