chap18.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:interviews 作者: alexksikes 项目源码 文件源码
def nsmallest(n, a):
    h = []
    for e in a[:n]:
        heapq.heappush(h, -e)  # we use a max heap but push -1 * e
    for e in a[n:]:
        heapq.heappushpop(h, -e)
    return -heapq.heappop(h)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号