[LeetCode 126] Word Ladder II

Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such that:

    1. Only one letter can be changed at a time
    1. Each intermediate word must exist in the word list

For example,

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

Return

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

Note:

  • All words have the same length.
  • All words contain only lowercase alphabetic characters.

Diffculty
Hard

Similar Problems

[LeetCode 127] Word Ladder M

Analysis

Solutions
Reference

results matching ""

    No results matching ""