576. Remove All Adjacent Duplicates in String

EasyStackStackString

Given a string s, repeatedly remove two adjacent equal characters until no such pair remains, and return the final string. The input is JSON {s}.

Input: JSON {s}.

Output: String — the reduced string.

Examples

Example 1
Input: {"s":"abbaca"}
Output: ca
Explanation: Remove bb, then aa, leaving ca.
Example 2
Input: {"s":"azxxzy"}
Output: ay
Explanation: Remove xx then zz.
Example 3
Input: {"s":"aaaa"}
Output: 
Explanation: All pairs cancel.

Constraints

Asked by

PaytmMetaDeloitteAppleAmazonOracle
Solve this problem in the editor →