Frage im Vorstellungsgespräch bei Uber

time Complexity, How i would optimize from original solution.