classSolution: defkClosest(self, points: List[List[int]], k: int) -> List[List[int]]: n = len(points) distances = [0] * n for index, (x, y) in enumerate(points): distances[index] = x * x + y * y indexes = sorted(list(range(n)), key=lambda i: distances[i]) return [points[i] for i in indexes[:k]] # return sorted(points, key=lambda x: x[0] * x[0] + x[1] * x[1])[:k]