mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 04:31:55 +08:00
Update code extractor of Java.
This commit is contained in:
@ -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) {
|
||||
// 将列表元素原封不动添加进堆
|
||||
|
||||
Reference in New Issue
Block a user