β¨ Leetcode
What are the environments for the programming languages? - Leetcode
Leetcode supports the following open source library as default.
For Priority Queue / Queue data structures,
you may use version 4.1 datastructures-js/priority-queue and datastructures-js/queue.
const minHeap = new MinPriorityQueue({ compare: (a, b) => a - b });
const maxHeap = new MaxPriorityQueue({ compare: (a, b) => b - a });
for (const num of nums) {
minHeap.enqueue(num);
maxHeap.enqueue(num);
}
while (maxHeap.size()) {
const check = maxHeap.front();
const max = maxHeap.dequeue();
}
while (minHeap.size()) {
const check = minHeap.front();
const min = minHeap.dequeue();
}
// methods
{
min, max;
}
Heap.size();
{
min, max;
}
Heap.isEmpty();
{
min, max;
}
Heap.toArray();
β¨ Implementation
...
ποΈ Typical problems
List
- Heap - Top K Pattern - List by @sachin_ak
- Heap - Merge Pattern - List by @sachin_ak
- Heap - Two Heap Pattern - List by @sachin_ak
- Heap - Min Number Pattern - List by @sachin_ak