implementing solution for median-of-stream problem