Find the shortest way to turn hit into cog by changing one letter at a time. Each intermediate word must be in the dictionary: ["hot","dot","dog","lot","log","cog"]. The answer is the number of words in the sequence.
I ran DFS and it returned a path immediately. But I noticed two valid routes exist. Before we go further — which one is shorter?
Which path is shorter? Tap it.