Uber interview question

Solve this coding problem within 45 minutes for round 1