Lyft interview question

1 Medium Leet code problem.