Multi-Source BFS Shortest Distances
Asked at Amazon · Coding Questions · Difficulty: Medium
Given an undirected graph as a list of `nodes` and `edges` (each edge a pair of nodes), plus a list of `sources`, compute the shortest-path distance from the nearest source to every node using multi-source BFS. Return a dict mapping each node to its distance.
Loading the problem…