FunctionRacerProblemsRace

Make The String Great

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

Two neighbouring characters clash if they are the same letter in different cases, like a and A. Repeatedly delete any clashing neighbour pair until none is left, and return the final string (it may be empty). The result does not depend on the order of deletions.

Example 1

s "leEeetcode"
returns "leetcode"

Remove eE to get leetcode.

Example 2

s "abBAcC"
returns ""

Everything cancels, leaving an empty string.

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