577. Make String Great

EasyStackStackString

Given a string s, repeatedly remove two adjacent characters that are the same letter in different cases (like 'a' and 'A') until none remain, and return the resulting string. The input is JSON {s}.

Input: JSON {s}.

Output: String — the good string.

Examples

Example 1
Input: {"s":"leEeetcode"}
Output: leetcode
Explanation: Remove the adjacent 'Ee'.
Example 2
Input: {"s":"abBAcC"}
Output: 
Explanation: Everything cancels.
Example 3
Input: {"s":"s"}
Output: s
Explanation: Single character stays.

Constraints

Asked by

GoogleBloombergMicrosoftAmazon
Solve this problem in the editor →