Uber interview question

How can you find a more optimal solution