Problems > Fewest Hops > Editorial

Fewest Hops — Solution & Editorial

Back to the Problem

BFS from S computes shortest unweighted distances layer by layer.

Complexity: O(N + M)