How leetcode deletes all adjacent duplicates in a string
This article mainly shows you "leetcode how to delete all adjacent duplicates in the string", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "leetcode how to delete all adjacent duplicates in the string" this article.
I. the content of the topic
Given the string S consisting of lowercase letters, the duplicate deletion operation selects two adjacent and identical letters and deletes them.
Repeat the delete operation on S until the deletion cannot continue.
Returns the final string after all duplicates are deleted. The answer is guaranteed only.
Example:
Enter: "abbaca"
Output: "ca"
Explanation:
For example, in "abbaca", we can delete "bb" because the two letters are adjacent and the same, which is the only duplicate that can be deleted at this time. Then we get the string "aaca", where only "aa" can delete duplicates, so the final string is "ca".
Tip:
one