Coding Challenge

Word Ladder

Hard
graphbfsstring

Find the shortest transformation sequence length between words.

Transform beginWord into endWord by changing one letter at a time, with every intermediate word required to exist in the dictionary. Return the shortest transformation length.

Examples

Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log","cog"]

Output: 5

Constraints

  • All words have equal length

Preparing your coding workspace...