String Remaining After Equal-Neighbor Erasure. Starting with lowercase string s, repeatedly erase an adjacent pair of equal letters until no such pair remains.
### Problem
Starting with lowercase string s, repeatedly erase an adjacent pair of equal letters until no such pair remains. Return the final string. The source guarantees this final string is unique, regardless of valid removal order.
```cpp
class Solution {
public:
string removeDuplicates(string s);
};
```
### Examples
**Example 1:**
```text
Input: s = "abccba"
Output: ""
Explanation: Erase cc, then bb, then aa.
```
**Example 2:**
```text
Input: s = "aabccb"
Output: ""
Explanation: Erase aa and cc; the remaining bb also disappears.
```
### Constraints
- The input has between 1 and 100000 characters.
- Every character is a lowercase English letter.
### Contract considerations
Only adjacent equal pairs may be erased. An empty final string is valid.
```hint Read the boundary condition
Can erasing a pair make two letters that were previously separated become adjacent?
```
### Boundary reminders
Only adjacent equal pairs may be erased. An empty final string is valid.
Overview: String Remaining After Equal-Neighbor Erasure. Starting with lowercase string s, repeatedly erase an adjacent pair of equal letters until no such pair remains.
Starting with lowercase string s, repeatedly erase an adjacent pair of equal letters until no such pair remains. Return the final string. The source guarantees this final string is unique, regardless of valid removal order.
class Solution {
public:
string removeDuplicates(string s);
};
Examples
Example 1:
Input: s = "abccba"
Output: ""
Explanation: Erase cc, then bb, then aa.
Example 2:
Input: s = "aabccb"
Output: ""
Explanation: Erase aa and cc; the remaining bb also disappears.
Constraints
The input has between 1 and 100000 characters.
Every character is a lowercase English letter.
Contract considerations
Only adjacent equal pairs may be erased. An empty final string is valid.
Boundary reminders
Only adjacent equal pairs may be erased. An empty final string is valid.