[LeetCode] 138: Word Ladder II

来源:互联网 发布:java 打印map 编辑:程序博客网 时间:2024/06/04 19:18
[Problem]

Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:

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

For example,

Given:
start = "hit"
end = "cog"
dict = ["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.

[Solution]
wait a moment
说明:版权所有,转载请注明出处。Coder007的博客