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.