You are viewing a single comment's thread. Return to all comments →
Simple solution
import bisect def median(a,x): ll=[] for (l,r) in zip(a,x): if l=='r': if r in ll: index=bisect.bisect(ll,r) ll.pop(index-1) else: print("Wrong!") continue else: bisect.insort(ll,r) if(len(ll)==0): print("Wrong!") continue median=(ll[len(ll)//2]+ll[(len(ll)-1)//2])/2 x=str(median) x=x.rstrip('0') x=x.rstrip('.') print(x)
Seems like cookies are disabled on this browser, please enable them to open this website
Median Updates
You are viewing a single comment's thread. Return to all comments →
Simple solution