← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Problem Statement
You are given a string s consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing them. We repeatedly make duplicate removals on s until we can no longer do so. Return the final string after all such duplicate removals have been made.[1][9]
Input/Output Examples
Input: s = "abccba"
Output: ""
Explanation: Remove "cc" → "abba"; remove "bb" → "aa"; remove "aa" → empty string.[1]
Input: s = "foobar"
Output: "fbar"
Explanation: Remove "oo" → "fbar".[1]
Input: s = "fooobar"
Output: "fobar"
Explanation: Remove "oo" → "fobar".[1]
Input: s = "abcd"
Output: "abcd"
Explanation: No adjacent duplicates, so no changes.[1]
Additional common example from sources:
s = "azxxzy""ca"Constraints
1 <= s.length <= 10^5s consists of lowercase English letters.[1]