Solve Shortest Paths and Rental Allocation | Google Coding Question