Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by
recursively removing all the consecutive duplicate pairs. In other words, He can apply the below
operations any number of times.
Remove all the consecutive duplicate pairs and concatenate the remaining string to replace
the original string.
Your task is to nd the string with minimum length after applying the above operations.
Example 1:
Input:
aaabbaaccd
Output:
ad
Explanation:
Remove (aa)abbaaccd =>abbaaccd
Remove a(bb)aaccd => aaaccd
Remove (aa)accd => accd
Remove a(cc)d => ad
---
就是连续的字符要相互抵消,看最后还剩什么字符,如果是空的,返回Empty String,
相邻字符抵消,可以用stack来处理。