Skip to content

evgeniyd/heapster-swift

Repository files navigation

CI-macOS

Heapster

MaxHeap.swift

MinHeap.swift

The Documentation with more info.

Problem

Heap is the data structure that I often has to drop into my Leetcode solutions. I implemented MinHeap and MaxHeap for educational purpose from scratch once, and started using it for Leetcode problems. This project exists so one can quickly copy-and-paste a Heap to a [Swift] Leetcode solutions.

Goals

  1. Simple AF
  2. Tested
  3. Minificated (Less lines of code)
  4. Performant enough

Notes:

  • Code is duplicated on purpose: the idea is one uses either MaxHeap or MinHeap by copying and pasting the source code into Leetcode code editor.
  • API of both Heaps is unified, except extractMin() vs. extractMax() to be more descriptive. It is a personal choice.
  • I am toying with this idea of minifying the source code, and creating a release versions of it. Similar to how minification is often done with JavaScript. In the end of the day, for the goals of this project, the code should not be readable as far as it delivers expected behavior.

TODO

  • Add test to MinHeap
  • Add tests to MaxHeap
  • Script to minify MinHeap
  • Script to minify MaxHeap
  • Move code comments to the documentation
  • Add performance tests

Leetcode

Problems that can be solved with Heap data structure.

About

Drop-in Min/Max Heap for Leetcode Problems (Swift)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published