find median in a fixed-size moving window along a long sequence of data

前端 未结 5 1165
挽巷
挽巷 2021-02-04 09:41

Given a sequence of data (it may have duplicates), a fixed-sized moving window, move the window at each iteration from the start of the data sequence, such that (1) the oldes

5条回答
  •  遥遥无期
    2021-02-04 10:26

    Same answer as hc_ but instead of using a stock BST use a version where every node has the count of elements in that sub-tree. This way finding median is O(log(m)).

提交回复
热议问题