The time complexity for the worst case(skew tree) would be O(n^2) right? If yes, how to optimise?
Can i do this question using queue?
No it will not be n^2. As you are pushing only the nodes in the queue. The total complexity will be 0(n)
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.