You are given a string s consisting of lowercase English letters.
You must repeatedly perform the following operation while the string s has at least two consecutive characters:
Return the resulting string after no more operations can be performed.
Note: Consider the alphabet as circular, thus 'a' and 'z' are consecutive.
Examples
Example 1
Input: s = "abc"
Output: "c"
Explanation:
Example 2
Input: s = "adcb"
Output: ""
Explanation:
Example 3
Input: s = "zadb"
Output: "db"
Explanation:
Constraints
1 <= s.length <= 105
s consists only of lowercase English letters.
3561. Resulting String After Adjacent Removals
Medium
30 Points
String
Stack
Simulation
You are given a string s consisting of lowercase English letters.
You must repeatedly perform the following operation while the string s has at least two consecutive characters:
Return the resulting string after no more operations can be performed.
Note: Consider the alphabet as circular, thus 'a' and 'z' are consecutive.
Examples
Example 1
Input: s = "abc"
Output: "c"
Explanation:
Example 2
Input: s = "adcb"
Output: ""
Explanation:
Example 3
Input: s = "zadb"
Output: "db"
Explanation:
Constraints
1 <= s.length <= 105
s consists only of lowercase English letters.
Resulting String After Adjacent Removals - Practice Coding | SlaveCode