CT036

Stepword Chain Transformation

HardAcceptance: 0.0%

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:

Input: dog cat 4 dot dop dat cat
Output: dog dot dat cat

Example 2:

Input: dog cat 4 dot tod dat dar
Output: null

Constraints:

1 <= word length <= 10 1 <= n <= 10^4 All words are lowercase and same length

Tags:

graph bfs strings
Loading...
Test Cases:No test cases
No test cases available.
Coding Problem Not Found | CodeTikki