RouteOne Interview Question

How would you solve this code challenge?