educative.io

What is the best solution out of the 3 solutions provided?

Level Order Traversal of Binary Tree - What is the best solution out of the 3 solutions provided?

Hi Jayesh,
As you can see the third solution cannot be best as it has more time complexity than first and second.
First and second solution takes same time and space complexity and less than third. So both of them are best. First one uses two queues while second uses one. It depends on you whether you like to use two queues or one. For me, one queue is better.