1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-12-21 11:13:46 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2025-09-29 14:43:44 +08:00
parent 2862a227c4
commit 13f2098086
4409 changed files with 168933 additions and 166256 deletions

View File

@@ -1,10 +1,10 @@
<p>一个下标从&nbsp;<strong>0</strong>&nbsp;开始的字符串数组&nbsp;<code>words</code>&nbsp;,和一个下标从 <strong>0</strong>&nbsp;开始的 <strong>二进制</strong>&nbsp;数组&nbsp;<code>groups</code>&nbsp;,两个数组长度都是&nbsp;<code>n</code>&nbsp;</p>
<p>一个字符串数组&nbsp;<code>words</code>&nbsp;,和一个&nbsp;<strong>二进制</strong>&nbsp;数组&nbsp;<code>groups</code>&nbsp;,两个数组长度都是&nbsp;<code>n</code>&nbsp;</p>
<p>你需要从&nbsp;<code>words</code>&nbsp;中选出&nbsp;<strong>最长<span data-keyword="subsequence-array">子序列</span></strong>。如果对于序列中的任两个连续串,二进制数组&nbsp;<code>groups</code>&nbsp;它们的对应元素不同,则&nbsp;<code>words</code> 的子序列是不同的。</p>
<p>如果&nbsp;<code>words</code>&nbsp;的一个 <span data-keyword="subsequence-array">子序列</span> 是交替的,那么对于序列中的任两个连续字符串,它们在&nbsp;<code>groups</code>&nbsp;相同索引的对应元素<strong>不同</strong> 的(也就是说,不能有连续的 0 或 1</p>
<p>正式来说,你需要从下标&nbsp;<code>[0, 1, ..., n - 1]</code>&nbsp;中选出一个&nbsp;<strong>最长子序列</strong>&nbsp;,将这个子序列记作长度为 <code>k</code>&nbsp;<code>[i<sub>0</sub>, i<sub>1</sub>, ..., i<sub>k - 1</sub>]</code>&nbsp;,对于所有满足&nbsp;<code>0 &lt;= j&nbsp;&lt; k - 1</code>&nbsp;&nbsp;<code>j</code>&nbsp;都有&nbsp;<code>groups[i<sub>j</sub>] != groups[i<sub>j + 1</sub>]</code>&nbsp;</p>
<p>你需要从&nbsp;<code>words</code>&nbsp;中选出&nbsp;<strong>最长交替<span data-keyword="subsequence-array">子序列</span></strong></p>
<p>请你返回一个字符串数组,它是下标子序列&nbsp;<strong>依次</strong>&nbsp;对应&nbsp;<code>words</code>&nbsp;数组中的字符串连接形成的字符串数组。如果有多个答案,返回 <strong>任意</strong> 一个。</p>
<p>返回选出的子序列。如果有多个答案,返回 <strong>任意</strong> 一个。</p>
<p><b>注意:</b><code>words</code>&nbsp;中的元素是不同的&nbsp;</p>