Dsa
Stack
Warm-up
Echo Cancellation
A radio signal transmits characters one by one. Occasionally, an 'echo' occurs where the same character is repeated twice consecutively (e.g., 'aa'). When this happens, both characters cancel each other out and disappear. This can cause a chain reaction (e.g., in 'abbaf', 'bb' cancels, leaving 'aaf', then 'aa' cancels, leaving 'f'). Given a string, return the final signal after all possible cancellations.
Example:
Input: abccba
Output: (empty string)
Key concepts
stackstring reduction
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