← 返回 bytedance 的题目列表Remove Duplicate Letters
类型:online_judge
Problem: Remove Duplicate Letters
Given a string s containing only lowercase English letters, remove duplicate letters so that every distinct letter appears exactly once in the result.
Among all valid results, return the string with the smallest lexicographical order.
Input Format
One line containing the string s
Output Format
Print the lexicographically smallest string after removing duplicate letters
Constraints
1 <= len(s) <= 10^4
s consists of lowercase English letters only
Example 1
Input:
bcabc
Output:
abc
Example 2
Input:
cbacdcbc
Output:
acdb
Example
Input
bcabc
Output
abc