考察堆的使用

class Solution:
    def GetLeastNumbers_Solution(self , input: List[int], k: int) -> List[int]:
        # write code here
        if not input or k == 0:
            return []
        import heapq
        heapq.heapify(input)
        res = []
        for _ in range(min(k, len(input))):
            res.append(heapq.heappop(input))
        return res