mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 04:31:55 +08:00
refactor:Simplified lambda expressions for PriorityQueue in heap.md and heap.java (#379)
This commit is contained in:
@ -28,7 +28,7 @@ public class heap {
|
||||
// 初始化小顶堆
|
||||
Queue<Integer> minHeap = new PriorityQueue<>();
|
||||
// 初始化大顶堆(使用 lambda 表达式修改 Comparator 即可)
|
||||
Queue<Integer> maxHeap = new PriorityQueue<>((a, b) -> { return b - a; });
|
||||
Queue<Integer> maxHeap = new PriorityQueue<>((a, b) -> b - a);
|
||||
|
||||
System.out.println("\n以下测试样例为大顶堆");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user