114. Word Ladder

HardGraph

Given two words, beginWord and endWord, and a dictionary wordList, return the number of words in the shortest transformation sequence from beginWord to endWord, or 0 if no such sequence exists. Every adjacent pair of words differs by a single letter.

Examples

Input: hit cog ["hot","dot","dog","lot","log","cog"]

Output: 5

Explanation: Public test case for Word Ladder

Constraints

  • 1 <= beginWord.length <= 10
  • endWord.length == beginWord.length
Loading...

Run checks all cases above. Submit evaluates all test cases.