Update code extractor of Java.

This commit is contained in:
krahets
2023-02-07 19:05:19 +08:00
parent 95bffcfb36
commit 8f512c2840
9 changed files with 99 additions and 87 deletions

View File

@ -9,16 +9,11 @@ package chapter_heap;
import include.*;
import java.util.*;
/* 最大堆类 */
/* 大顶堆 */
class MaxHeap {
// 使用列表而非数组,这样无需考虑扩容问题
private List<Integer> maxHeap;
/* 构造函数,建立空堆 */
public MaxHeap() {
maxHeap = new ArrayList<>();
}
/* 构造函数,根据输入列表建堆 */
public MaxHeap(List<Integer> nums) {
// 将列表元素原封不动添加进堆