trekhleb / javascript-algorithms

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
MIT License
184.97k stars 29.83k forks source link

fix(heap): `this` is `undefined` #1124

Open ojj1123 opened 2 months ago

ojj1123 commented 2 months ago

What's the problem?

https://github.com/trekhleb/javascript-algorithms/pull/1117

This PR contains several minimalistic (by their functionalities and implementation) data structures like MinHeap, MaxHeap, and DisjointSet that don't have external dependencies and that are easy to copy-paste and use during the coding interview if allowed by the interviewer.

How to fix

this.heap.forEach((value) => this.add(value));
ojj1123 commented 2 months ago

@trekhleb I was wondering if you could review this PR! I think it is important since your intend could be broken up.