1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/最小基因变化 [minimum-genetic-mutation].html
2022-03-29 12:43:11 +08:00

50 lines
1.6 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>一条基因序列由一个带有8个字符的字符串表示其中每个字符都属于 <code>"A"</code>, <code>"C"</code>, <code>"G"</code>, <code>"T"</code>中的任意一个。</p>
<p>假设我们要调查一个基因序列的变化。<strong>一次</strong>基因变化意味着这个基因序列中的<strong>一个</strong>字符发生了变化。</p>
<p>例如,基因序列由<code>"AACCGGTT"</code> 变化至 <code>"AACCGGTA" </code>即发生了一次基因变化。</p>
<p>与此同时,每一次基因变化的结果,都需要是一个合法的基因串,即该结果属于一个基因库。</p>
<p>现在给定3个参数 — start, end, bank分别代表起始基因序列目标基因序列及基因库请找出能够使起始基因序列变化为目标基因序列所需的最少变化次数。如果无法实现目标变化请返回 -1。</p>
<p><strong>注意:</strong></p>
<ol>
<li>起始基因序列默认是合法的,但是它并不一定会出现在基因库中。</li>
<li>如果一个起始基因序列需要多次变化,那么它每一次变化之后的基因序列都必须是合法的。</li>
<li>假定起始基因序列与目标基因序列是不一样的。</li>
</ol>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
start: "AACCGGTT"
end: "AACCGGTA"
bank: ["AACCGGTA"]
返回值: 1
</pre>
<p><strong>示例 2</strong></p>
<pre>
start: "AACCGGTT"
end: "AAACGGTA"
bank: ["AACCGGTA", "AACCGCTA", "AAACGGTA"]
返回值: 2
</pre>
<p><strong>示例 3</strong></p>
<pre>
start: "AAAAACCC"
end: "AACCCCCC"
bank: ["AAAACCCC", "AAACCCCC", "AACCCCCC"]
返回值: 3
</pre>