Median in a stream of running integers

i am getting a wrong output.
Please look into it.

logic is correct
but there is one mistake at line no 31 and 50
you have written
med=(leftheap.top()+rightheap.top()/2);
which is wrong
correct statement is
med=(leftheap.top()+rightheap.top())/2;

closing brace comes earlier

Modified Code

if you want to ask something about this feel free to ask
i hope this helps
if yes show your response with :heart: and don’t forgot to mark doubt as resolved

1 Like