BFS with a visited set

BFS0:00

BFS over an adjacency Map<Integer,List<Integer>> from start.

Type it from memory — say each line out loud as you write it. Then check.