MicrosoftOA #3
Erase Pairs of Identical Letters
估计中等可在线判题
Each operation may delete any two equal letters, which do not need to be adjacent; the remaining characters keep their relative order. First minimize the length, then find the lexicographically smallest string among those of that length. Some of the original site's examples deleted the wrong characters; this site recomputed them under this explicit definition.
输入格式
One line of 1..100000 uppercase English letters.
输出格式
Output the final string; if it is empty, output an empty line.
样例 1
输入:
CBCAAXA
输出:
BAX
样例 2
输入:
ZYXZYZYV
输出:
XYZV
样例 3
输入:
ABCBACDDAB
输出:
AB
样例说明
Example 1: C has an even frequency and is deleted entirely, while B, A, and X are each kept once; the smallest result that preserves the order is BAX.
Example 2: Z, Y, X, and V all have odd frequencies, and the smallest feasible subsequence is XYZV.
Example 3: A and B each appear 3 times and C and D each appear 2 times; the shortest result is AB, not the empty string given by the original site.