Class Solution
java.lang.Object
g1001_1100.s1047_remove_all_adjacent_duplicates_in_string.Solution
1047 - Remove All Adjacent Duplicates In String.<p>Easy</p>
<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><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “abbaca”</p>
<p><strong>Output:</strong> “ca”</p>
<p><strong>Explanation:</strong></p>
<p>For example, in “abbaca” we could remove “bb” since the letters are adjacent and equal, and this is the only possible move.</p>
<p>The result of this move is that the string is “aaca”, of which only “aa” is possible, so the final string is “ca”.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “azxxzy”</p>
<p><strong>Output:</strong> “ay”</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>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
removeDuplicates
-