Problem 894
Make The String Great
Problem
A string is good if it never has two neighbouring characters that are the same letter in different cases, like aA or Bb. While the string has such a pair, remove it; removals can create new bad pairs, which are removed too. Print the final string, or EMPTY if nothing remains. A stack does this in one pass: push each character unless it forms a bad pair with the top, in which case pop the top instead.
Input
A single string S of English letters.
Output
Print the good string, or EMPTY.
Constraints
1 <= |S| <= 100000
Example input
leEeetcode
Example output
leetcode
Explanation
In leEeetcode, the pair eE is removed first, leaving leetcode, which has no bad pair. So the answer is leetcode.