1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-02-04 14:40:27 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/单词转换 [word-transformer-lcci].html

28 lines
863 B
HTML
Raw Normal View History

2022-03-27 20:38:29 +08:00
<p>给定字典中的两个词,长度相等。写一个方法,把一个词转换成另一个词, 但是一次只能改变一个字符。每一步得到的新词都必须能在字典中找到。</p>
<p>编写一个程序,返回一个可能的转换序列。如有多个可能的转换序列,你可以返回任何一个。</p>
2025-01-09 20:29:41 +08:00
<p><strong>示例 1</strong></p>
2022-03-27 20:38:29 +08:00
2025-01-09 20:29:41 +08:00
<pre>
<strong>输入:</strong>
beginWord = "hit",
endWord = "cog",
wordList = ["hot","dot","dog","lot","log","cog"]
2022-03-27 20:38:29 +08:00
2025-01-09 20:29:41 +08:00
<strong>输出:</strong>
["hit","hot","dot","lot","log","cog"]
2022-03-27 20:38:29 +08:00
</pre>
2025-01-09 20:29:41 +08:00
<p><strong>示例 2</strong></p>
2022-03-27 20:38:29 +08:00
2025-01-09 20:29:41 +08:00
<pre>
<strong>输入:</strong>
beginWord = "hit"
endWord = "cog"
wordList = ["hot","dot","dog","lot","log"]
2022-03-27 20:38:29 +08:00
2025-01-09 20:29:41 +08:00
<strong>输出:</strong>[]
2022-03-27 20:38:29 +08:00
2025-01-09 20:29:41 +08:00
<strong>解释:</strong><em>endWord</em> "cog" 不在字典中,所以不存在符合要求的转换序列。</pre>