Collapse Adjacent Pairs
Repeatedly delete any two equal adjacent characters until no such pair remains. Print the result, or EMPTY. The final string is unique regardless of deletion order.
Input: one line with the string S.
Output: the fully collapsed string, or EMPTY.
Constraints:
- 1 ≤ |S| ≤ 104
- S contains lowercase English letters
Sample Tests
Input 1
abbaca
Output 1
ca
Input 2
abba
Output 2
EMPTY
Discussion (opens after you solve — no spoilers before)
No comments yet.