Median in a stream of running integers


kindly comment out the errrors in this code, it doesnt pass any testcase.

image
Also why do we require a vector in the min heap but not a max heap here?

Hello @mkidwai74 i have corrected your code and commented the mistake:

@mkidwai74 max heap is by default which is formed so converting the max heap into minheap we have to reverse the comparator fucntion like this.

but for the comparator function we use greater,
i didnt understand why we also make priority queue of vectors

@mkidwai74 this is because we maintain heap in a vector.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.