New answers tagged


There probably are better ways but here goes. Let each transaction be denoted $(i,A_i)$ and let them arrive in a stream. Initialize a list $L:=[]$ which will be sorted on the second component. For the first $K$ transactions insert $(i,A_i)$ into the proper position in $L.$ Let $L[1]$ denote the smallest entry in $L.$ Since the maximum amount seen so far is ...

Top 50 recent answers are included