Sponsored
Use these hints if you're stuck. Try solving on your own first.
Start from each house, run a BFS to get all the distances from this house to all the other houses.
Solve with full IDE support and test cases