@yanzhan2 Well you can see in the discussion in the linked topic that I didn't directly write it like this, either, and that I had help from @votrubac :-). Btw, I had the basic idea (multiset and iterator pointing to the middle) when I first saw the problem, but thought it would get ugly and solved this problem in a different way. Then I saw @votrubac's solution which motivated me to try it myself. And when we ended up with the above solution, I was surprised myself about how nice it had ended up.
Sliding Window Median