Dsa
Stack
Easy
String Reduction by Stack
You are tasked with reducing a string by repeatedly removing adjacent pairs of the same character. For example, the string 'aabbcc' becomes '''. If the string is reduced completely, you should print 'EMPTY'.
Input format:
- A single line string with lowercase alphabetic characters (1 <= length <= 10^5).
Output format:
- Print the reduced string or 'EMPTY' if completely reduced.
Example:
Input:
aabbcc
Output:
EMPTY
Key concepts
stackreductionstring
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now