refactor:Simplified lambda expressions for PriorityQueue in heap.md and heap.java (#379)

This commit is contained in:
t8g
2023-02-22 19:35:49 +08:00
committed by GitHub
parent a2b74943a2
commit f2d2cca5f1
2 changed files with 2 additions and 2 deletions

View File

@ -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以下测试样例为大顶堆");