Ad
  • Custom User Avatar

    There is no "optimal" answer to the tests, there is only one possible answer for each test. You cannot rearrange the customers in line to take the shortest amount of time possible, you have to process the queue in the order that it's given to you. Just like in a real supermarket, they check people out in the order that they come to the registers. With that said, your code has a lot of issues, mostly because you're changing the order of the queue.