Remove Duplicate Letters

Given a string A consisting of lowercase English alphabets.
Find and return lexicographically smallest string B after removing duplicate letters from A
so that every letter appears once and only once.



Input Format

The only argument given is string A.

Output Format

Return lexicographically smallest string B after removing duplicate letters from A.

Constraints

1 <= length of the string <= 200000
A consists of lowercase English alphabets only. 

For Example

Input 1:
    A = "cbacdcbc"
Output 1:
    B = "acdb"

Input 2:
    A = "bcabc"
Output 2:
    B = "abc"
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Remove Duplicate Letters on Interview Code Editor
Sign Up
to access hints and editorial solutions for Remove Duplicate Letters

Discussion


Loading...
Click here to start solving coding interview questions