why am i getting TLE in this and 2 wrong answers.Is my approach that time consuming
If yes then provide an efficient approach
TLE and wrong answer
@D19APPPP0016,
Calculate the complexity of the code, you will yourself know, if it is inefficient or not.
And for a better approach. Try thinking like this, use 2 priority_queues, one min_heap and one_max_heap, both at any moment of time will store the stream of already inputed numbers, divided in two halves, where first half is smaller than the second half. In this case, the median would always be either or average of the 2 top elements of heaps.
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.