cswork / OA打开练习工作台

YahooOA #1

Modify the String

估计中等可在线判题

考点(AI 标注)单调栈与堆贪心调度

Delete repeated characters until all characters are distinct, and return the lexicographically largest order-preserving result.

See "Input" for the standard input/output conventions and constraints added by this site.

输入格式

A lowercase string of length 1..100000.

输出格式

Output the largest deduplicated subsequence.

样例 1

输入:

aabcb

输出:

acb

样例 2

输入:

bcabc

输出:

cab

样例 3

输入:

aaaa

输出:

a

样例 4

输入:

cbacdcbc

输出:

cbad