Undirected connected graph of n houses; a subset (solarPanels) have power. Every other house pulls electricity along unit-length wires to its nearest solar house. Return dist[i] = shortest path length from house i to any solar house (0 if it is one).
Asked in the DSA stage. Brute force BFS per house, then multi-source BFS; working code expected.
Implement shortest_distances(n, edges, solarPanels). Houses are numbered 0 through n - 1; edges contains undirected pairs [u, v]; solarPanels contains house indices. Return a list of length n.
def shortest_distances(n, edges, solarPanels):