Lyft Interview Question

1 Medium Leet code problem.