Practice Resulting String After Adjacent Removals
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Repeatedly remove the leftmost adjacent pair in s whose letters are consecutive in the alphabet in either order. Close the gap after each removal. The alphabet is circular, so a and z also form a removable pair. Return the string when no such pair remains.
Source: Resulting String After Adjacent Removals on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
s = "abc"
Output
"c"
# Example 2
Input
s = "adcb"
Output
""
# Example 3
Input
s = "zadb"
Output
"db"
Constraints
1 <= s.length <= 10^5
s consists only of lowercase English letters.
Related LeetCode Problems
Practice more problems similar to Resulting String After Adjacent Removals.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.