#3561
Resulting String After Adjacent Removals
specialist · 775 · lc medium +31 · 56.6% accepted · 89 likes · top 51%
Description
Given lowercase string s, repeatedly remove the leftmost adjacent pair of characters that are alphabetically consecutive (in either order, with \'z\' and \'a\' considered consecutive). Close the gap by shifting left.
Return the string that remains when no more such pairs exist.
Code
1
2
3