kClosest = function(points, k) {
    const maxHeap = new MaxPriorityQueue({ priority: (point) => distance(point) })

    for (const point of points) {
        const isUnderCapacity = maxHeap.size() < k;
        if (isUnderCapacity) {
            maxHeap.enqueue(point);
            continue;
        }

        const isCloser = distance(point) < distance(maxHeap.front().element);
        if (isCloser) {
            maxHeap.dequeue();
            maxHeap.enqueue(point);
        }
    }

    return maxHeap
        .toArray()
        .map(({ element }) => element);
}
https://leetcode.com/problems/k-closest-points-to-origin/
Time O(N * log(K)) | Space O(K)
@param {number[][]} points
@param {number} k
@return {number[][]}