122. Word Ladder Length
HardGraphs
Transform begin into end by changing one letter at a time, where every intermediate word (and end) must be in words. begin itself need not be in the list. Return the number of words in the shortest such sequence, counting both begin and end, or 0 if it is impossible.
All words have the same length and use lowercase letters; begin differs from end.
Example 1
Input: begin = "hit", end = "cog", words = ["hot","dot","dog","lot","log","cog"] Output: 5 Explanation: hit → hot → dot → dog → cog
Constraints
1 ≤ word length ≤ 101 ≤ words.length ≤ 5000