← 返回 bytedance 的题目列表Remove Duplicate Letters
类型:online_judge
Problem: Remove Duplicate Letters
Given a string s consisting only of lowercase English letters, remove duplicate letters so that every letter appears exactly once.
Return the lexicographically smallest possible result among all valid results. The returned string must preserve the relative order of characters from the original string.
Input Format
One line containing the string s.
Output Format
Output one string, the lexicographically smallest result after removing duplicate letters.
Constraints
1 <= s.length <= 10^4
s consists only of lowercase English letters.
Example 1
Input:
bcabc
Output:
abc
Example 2
Input:
cbacdcbc
Output:
acdb
Example
Input
bcabc
Output
abc