This is code also working fine, If I’m not wrong the overall complexity O(NLogN) but the approch is not special as discuss in video of heap.
Please tell can we use this?
This is code also working fine, If I’m not wrong the overall complexity O(NLogN) but the approch is not special as discuss in video of heap.
Please tell can we use this?
@as159925
Yes you can use this, but its complexity is higher. Its complexity NK log(N.K)
and also in interviews, interviewer would ask you the heap approach, just make sure that you know it.
the ideal soln is NK log(K)
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.