1. Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them. 2. We repeatedly make duplicate removals on S until we no longer can. 3. Return the final string after all such duplicate removals have been made. 4. It is guaranteed the answer is unique. Example Input: "abbaca" Output: "ca" Explanation: For example, in "abbaca" we could remove "bb" since the letters are adjacent and equal, and this is the only possible move. The result of this move is that the string is "aaca", of which only "aa" is possible, so the final string is "ca".
Input Format
A String
Output Format
A string
Constraints
1 <= S.length <= 20000 S consists only of English lowercase letters.
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
abbaca
Output
ca