mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	国外版
This commit is contained in:
		
							
								
								
									
										30
									
								
								算法题(国外版)/remove-all-adjacent-duplicates-in-string.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								算法题(国外版)/remove-all-adjacent-duplicates-in-string.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
<p>You are given a string <code>s</code> consisting of lowercase English letters. A <strong>duplicate removal</strong> consists of choosing two <strong>adjacent</strong> and <strong>equal</strong> letters and removing them.</p>
 | 
			
		||||
 | 
			
		||||
<p>We repeatedly make <strong>duplicate removals</strong> on <code>s</code> until we no longer can.</p>
 | 
			
		||||
 | 
			
		||||
<p>Return <em>the final string after all such duplicate removals have been made</em>. It can be proven that the answer is <strong>unique</strong>.</p>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Example 1:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> s = "abbaca"
 | 
			
		||||
<strong>Output:</strong> "ca"
 | 
			
		||||
<strong>Explanation:</strong> 
 | 
			
		||||
For example, in "abbaca" we could remove "bb" since the letters are adjacent and equal, and this is the only possible move.  The result of this move is that the string is "aaca", of which only "aa" is possible, so the final string is "ca".
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 2:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> s = "azxxzy"
 | 
			
		||||
<strong>Output:</strong> "ay"
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Constraints:</strong></p>
 | 
			
		||||
 | 
			
		||||
<ul>
 | 
			
		||||
	<li><code>1 <= s.length <= 10<sup>5</sup></code></li>
 | 
			
		||||
	<li><code>s</code> consists of lowercase English letters.</li>
 | 
			
		||||
</ul>
 | 
			
		||||
		Reference in New Issue
	
	Block a user