Remove All Adjacent Duplicates in String Problem

Remove All Adjacent Duplicates in String Problem — ExecCode Easy DSA Practice

Solve the Remove All Adjacent Duplicates in String problem on ExecCode. Free online easy DSA practice in Stack. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given a string s consisting of lowercase English letters. Your task is to compute the required answer and return the final string after all such duplicate removals have been made. A duplicate removal consists of choosing two adjacent and equal letters and removing them. We repeatedly make duplicate removals on s until we no longer can. It can be proven that the answer is unique.

Examples

Input {"s": "abbaca"}; Output ca. Input {"s": "azxxzy"}; Output ay. Input {"s": "a"}; Output a

Constraints

1 <= s.length <= 10^5 s consists of lowercase English letters.

Practice Remove All Adjacent Duplicates in String free on ExecCode. Browse DSA problems, topic map, and placement guides.