Account
Draft saved on this device
▤ DescriptionOriginal CppValley problem
Core C++Easy

Remove Adjacent Duplicate Characters

Repeatedly remove any pair of adjacent identical characters until no such pair remains.

Repeatedly remove any pair of adjacent identical characters until no such pair remains. A stack-like single pass can simulate the repeated removals because newly adjacent pairs must also vanish. Input consists of lowercase Latin letters.

Input format

One string S on one line.

Output format

Print the reduced string, or EMPTY when all characters are removed.

Examples

Example 1
Input
abbaca
Expected output
ca

Constraints

  • 1 ≤ |S| ≤ 100000
  • S contains only a–z.

Related concepts

Strings

This early-access exercise uses standard input/output. More advanced concurrency challenges will use specialized class interfaces, instrumentation, and stress tests once the judging infrastructure is ready.

⌘ CodeC++17
GNU C++17 · main.cpp

Loading Monaco C++ editor…

Checking judge...

Checking whether the external C++ judge is available.

⌁ Test cases & resultsPublic samples: 1
Input
abbaca
Expected output
ca
Execution requires a secure external judge.