FunctionRacerProblemsRace

Remove All Adjacent Duplicates

EasyStacks and queuesPython, JavaScript, TypeScript, Java, C++

Repeatedly pick two equal letters that sit next to each other and delete both. Keep going until no such pair remains, and return the final string. The result is the same whichever order you delete in.

Example 1

s "abbaca"
returns "ca"

Delete bb to get aaca, then delete aa to get ca.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Stacks and queues problems