K Closest Points to Origin
import heapq
class Solution:
def kClosest(self, points, k):
hq = []
for p in points:
hq.append((p[0]**2 + p[1]**2, p))
heapq.heapify(hq)
res = []
for _ in range(k):
res.append(heapq.heappop(hq)[1])
return res