剑指offer python版 数据流中的中位数

import heapq
import math
def aa(nums):
    mid=math.ceil(len(nums)/2)
    q=heapq.nlargest(mid,nums)[-1]
    m=heapq.nsmallest(mid,nums)[-1]    
    
    return (m+q)/2


print(aa([1,2,3,3,4,5]))
原文地址:https://www.cnblogs.com/xzm123/p/9856715.html