<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>子序列 on 一共十七划</title>
		<link>https://noirzh.com/tags/%E5%AD%90%E5%BA%8F%E5%88%97/</link>
		<description>Recent content in 子序列 on 一共十七划</description>
		<generator>Hugo</generator>
		<language>zh-CN</language>
		
		
		
		
			<lastBuildDate>Tue, 07 Nov 2023 10:37:15 +0800</lastBuildDate>
		
			<atom:link href="https://noirzh.com/tags/%E5%AD%90%E5%BA%8F%E5%88%97/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>题解-最长相邻不相等子序列 II</title>
				<link>https://noirzh.com/solution-longest-unequal-adjacent-groups-subsequence-ii/</link>
				<pubDate>Sun, 15 Oct 2023 02:42:00 +0800</pubDate>
				<guid>https://noirzh.com/solution-longest-unequal-adjacent-groups-subsequence-ii/</guid>
				<description>&lt;blockquote&gt;&#xD;&#xA;&lt;p&gt;Problem:&lt;a href=&#34;https://leetcode.cn/problems/longest-unequal-adjacent-groups-subsequence-ii/description/&#34;&gt;最长相邻不相等子序列&lt;/a&gt;&lt;/p&gt;&#xD;&#xA;&lt;/blockquote&gt;&#xD;&#xA;&lt;h2&gt;&lt;strong&gt;题目&lt;/strong&gt;&lt;/h2&gt;&#xD;&#xA;&lt;p&gt;给你一个整数 &lt;code&gt;n&lt;/code&gt; 和一个下标从 &lt;strong&gt;0&lt;/strong&gt; 开始的字符串数组 &lt;code&gt;words&lt;/code&gt; ，和一个下标从 &lt;strong&gt;0&lt;/strong&gt; 开始的数组 &lt;code&gt;groups&lt;/code&gt; ，两个数组长度都是 &lt;code&gt;n&lt;/code&gt; 。&lt;/p&gt;&#xD;&#xA;&lt;p&gt;两个长度相等字符串的 &lt;strong&gt;汉明距离&lt;/strong&gt; 定义为对应位置字符 &lt;strong&gt;不同&lt;/strong&gt; 的数目。&lt;/p&gt;&#xD;&#xA;&lt;p&gt;你需要从下标 &lt;code&gt;[0, 1, ..., n - 1]&lt;/code&gt; 中选出一个 &lt;strong&gt;最长子序列&lt;/strong&gt; ，将这个子序列记作长度为 &lt;code&gt;k&lt;/code&gt; 的 &lt;code&gt;[i&lt;sub&gt;0&lt;/sub&gt;, i&lt;sub&gt;1&lt;/sub&gt;, ..., i&lt;sub&gt;k - 1&lt;/sub&gt;]&lt;/code&gt; ，它需要满足以下条件：&lt;/p&gt;&#xD;&#xA;&lt;ul&gt;&#xD;&#xA;&lt;li&gt;&lt;strong&gt;相邻&lt;/strong&gt; 下标对应的 &lt;code&gt;groups&lt;/code&gt; 值 &lt;strong&gt;不同&lt;/strong&gt;。即，对于所有满足 &lt;code&gt;0 &amp;lt; j + 1 &amp;lt; k&lt;/code&gt; 的 &lt;code&gt;j&lt;/code&gt; 都有 &lt;code&gt;groups[i&lt;sub&gt;j&lt;/sub&gt;] != groups[i&lt;sub&gt;j + 1&lt;/sub&gt;]&lt;/code&gt; 。&lt;/li&gt;&#xD;&#xA;&lt;li&gt;对于所有 &lt;code&gt;0 &amp;lt; j + 1 &amp;lt; k&lt;/code&gt; 的下标 &lt;code&gt;j&lt;/code&gt; ，都满足 &lt;code&gt;words[i&lt;sub&gt;j&lt;/sub&gt;]&lt;/code&gt; 和 &lt;code&gt;words[i&lt;sub&gt;j + 1&lt;/sub&gt;]&lt;/code&gt; 的长度 &lt;strong&gt;相等&lt;/strong&gt; ，且两个字符串之间的 &lt;strong&gt;汉明距离&lt;/strong&gt; 为 &lt;code&gt;1&lt;/code&gt; 。&lt;/li&gt;&#xD;&#xA;&lt;/ul&gt;&#xD;&#xA;&lt;p&gt;请你返回一个字符串数组，它是下标子序列 &lt;strong&gt;依次&lt;/strong&gt; 对应 &lt;code&gt;words&lt;/code&gt; 数组中的字符串连接形成的字符串数组。如果有多个答案，返回任意一个。&lt;/p&gt;&#xD;&#xA;&lt;p&gt;&lt;strong&gt;子序列&lt;/strong&gt; 指的是从原数组中删掉一些（也可能一个也不删掉）元素，剩余元素不改变相对位置得到的新的数组。&lt;/p&gt;&#xD;&#xA;&lt;p&gt;&lt;strong&gt;注意：&lt;/strong&gt;&lt;code&gt;words&lt;/code&gt; 中的字符串长度可能 &lt;strong&gt;不相等&lt;/strong&gt; 。&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
