Given a begin word, an end word, and a dictionary, return all of the shortest transformation sequences. Pattern focus: BFS shortest path in unweighted graph. Use BFS for minimum distance and parent tracking to reconstruct every shortest path.
beginWord = start word, endWord = target word, wordList = dictionary
all shortest transformation sequences
Example 1:
Input:
beginWord = "hit" endWord = "cog" wordList = ["hot","dot","dog","lot","log","cog"]
Output:
[["hit","hot","dot","dog","cog"],["hit","hot","lot","log","cog"]]
Explanation:
There are two shortest transformation sequences of equal length.
Example 2:
Input:
beginWord = "hit" endWord = "cog" wordList = ["hot","dot","dog","lot","log"]
Output:
[]
Explanation:
No valid sequence reaches the end word.