0–1 BFS

Find the cheapest fare from the start to each town on a map where a road costs either one coin or nothing.

A free move goes to the front of the deque and a paid move goes to the back. The program builds a deque from two lists.

With adjacency lists, traversal takes O(V + E) time for V vertices and E edges.