i have used the same logic as taught in videos but still 2 test cases are giving tle.
Why are 2 test cases giving tle?
please share your code and logic as well.
https://ide.codingblocks.com/s/313683 i have taken 2 priority queues , 1 max and another min and maintained them accordingly.
Your logic is correct, however your code is not optimised.
Check this link to get a better idea of how to implement the same logic.
https://www.tutorialspoint.com/median-in-a-stream-of-integers-running-integers-in-cplusplus#:~:text=%20Median%20in%20a%20stream%20of%20integers%20(running,15%2020%20Published%20on%2010-Feb-2020%2014%3A51%3A31%20More%20
Still any doubt, feel free to message
the code which is there in the link is quite big and uses unnecessary functions whereas simple operations like counting can be performed using predefined class. i have also written the same code taught by sir in the videos. u please modify my code.
Logic wise I dont see any error. Try using p.size == q.size + 1 in the while loop if else checks rather than p.size > q.size. Similarly for the else part use q.size == p.size + 1. Rest I dont see any errors.
Another thing is that I dont know what was taught to you in the videos codewise and stuff since the videos are private to the students only. So I would recommend double checking the parts you have taken from there, since a lot of times students copy incorrect code or typo errors while copying stuff and then it gets very hard to debug as what they believe is correct is wrong (an example as student while copying >= from video code took it as != in his own code leading to error)
sir, is the == operator faster than >< operator ?
No all logical operators are same speed
when i used > operator, it was giving tle but when i used ==, there was no tle. Rest of the code was same, can u tell me why?
It is not because of operator speed, but because of elimination of test cases.
With == you were outrightly rejecting the wrong answers
With > some test cases like more than 1 element were also being processed, thus taking taking up your computing time and giving Time Limit Exceeded(tle)
okay, i got it. thank you sir!