A string is good when no two neighbouring characters are the same letter in opposite cases, such as `"aA"` or `"Bb"`. Given a string `s` of English letters, repeatedly delete such a neighbouring pair until the string is good, and return it. The answer is unique, and an empty string counts as good.
A string is good when no two neighbouring characters are the same letter in opposite cases, such as "aA" or "Bb". Given a string s of English letters, repeatedly delete such a neighbouring pair until the string is good, and return it. The answer is unique, and an empty string counts as good.
Example 1:
Input: {"s":"leEeetcode"}
Output: leetcode
Constraints:
1≤s.length≤100
s contains only lowercase and uppercase English letters.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s":"leEeetcode"}
s: cancelled twins share a colour
lowercase · UPPERCASE
l
0
e
1
E
2
e
3
e
4
t
5
c
6
o
7
d
8
e
9
Read the letters left to right. The stack holds the good prefix so far; a new letter can only clash with the top.