intermediateGraphs
Shortest path in an unweighted graph
Given an undirected graph and two nodes, find the length of the shortest path between them. Every edge costs 1.
Examples
input 0-1, 1-2, 2-3, 0-3, from 0 to 3
output 1
A direct edge exists.
input 0-1, 1-2, 2-3, from 0 to 3
output 3
You must visit 1 and 2 first.
Hints
Try the problem first. Hints are revealed one at a time so you keep thinking.
Solution
The written approach, complexity analysis and follow-ups stay hidden until you ask for them.