mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>一个字符串如果没有 <strong>三个连续</strong> 相同字符,那么它就是一个 <strong>好字符串</strong> 。</p>
 | 
						||
 | 
						||
<p>给你一个字符串 <code>s</code> ,请你从 <code>s</code> 删除 <strong>最少</strong> 的字符,使它变成一个 <strong>好字符串</strong> 。</p>
 | 
						||
 | 
						||
<p>请你返回删除后的字符串。题目数据保证答案总是 <strong>唯一的 </strong>。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<b>输入:</b>s = "le<strong>e</strong>etcode"
 | 
						||
<b>输出:</b>"leetcode"
 | 
						||
<strong>解释:</strong>
 | 
						||
从第一组 'e' 里面删除一个 'e' ,得到 "leetcode" 。
 | 
						||
没有连续三个相同字符,所以返回 "leetcode" 。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<b>输入:</b>s = "<strong>a</strong>aab<strong>aa</strong>aa"
 | 
						||
<b>输出:</b>"aabaa"
 | 
						||
<strong>解释:</strong>
 | 
						||
从第一组 'a' 里面删除一个 'a' ,得到 "aabaaaa" 。
 | 
						||
从第二组 'a' 里面删除两个 'a' ,得到 "aabaa" 。
 | 
						||
没有连续三个相同字符,所以返回 "aabaa" 。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 3:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<b>输入:</b>s = "aab"
 | 
						||
<b>输出:</b>"aab"
 | 
						||
<b>解释:</b>没有连续三个相同字符,所以返回 "aab" 。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= s.length <= 10<sup>5</sup></code></li>
 | 
						||
	<li><code>s</code> 只包含小写英文字母。</li>
 | 
						||
</ul>
 |