Description
Given a string s of lower and upper case English letters, make the string good by removing two adjacent characters that are the same letter but different cases. Return the resulting string.
Examples
Input:
s = "leEeetcode"Output:
"leetcode"Explanation:
Using a stack: push 'l', push 'e'. Next 'E' matches 'e' (same letter, different case), so pop 'e'. Stack=['l']. Push 'e','e','t','c','o','d','e'. Final stack=['l','e','e','t','c','o','d','e'] = 'leetcode'.
Input:
s = "a"Output:
"a"Explanation:
A single character has no adjacent pair to remove, so the string is already great.
Input:
s = "abBAcC"Output:
""Explanation:
Stack approach: push 'a','b'. Next 'B' matches 'b', pop. Stack=['a']. Next 'A' matches 'a', pop. Stack=[]. Push 'c'. Next 'C' matches 'c', pop. Stack=[]. Result is empty string.
Constraints
- •
1 ≤ s.length ≤ 100