Since Python's heapq implementation does not have built in support for max heap, we can just invert the values stored into the heap so it functions as a max heap. Max heap is better than min heap because we don't actually have to store all N points into the heap, we just need to keep K min points.
Time Complexity: O(N Log(K))
Space Complexity: O(K)
Since Python's heapq implementation does not have built in support for max heap, we can just invert the values stored into the heap so it functions as a max heap. Max heap is better than min heap because we don't actually have to store all N points into the heap, we just need to keep K min points.
Time Complexity: O(N Log(K)) Space Complexity: O(K)