The Codetikki word alchemists transform words one letter at a time. Given a start word, an end word, and a dictionary of valid words, find the shortest transformation sequence from start to end where only one letter changes at each step and each intermediate word must be in the dictionary. Input: first line start and end words, second line n (dictionary size), third line n dictionary words. Output: the transformation sequence as space-separated words, or "null" if impossible.
Example 1:
Example 2:
Constraints:
1 <= word length <= 10 1 <= n <= 10^4 All words are lowercase and same length
Tags:
