Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Remove Duplicate Letters

XPChallenge Points: 20
levelLevel: Medium

You are given a string text consisting of lowercase English letters.
Your task is to remove duplicate letters so that each letter appears exactly once in the resulting string.

The final string must be the smallest possible in lexicographical order among all valid results.

Example 1:

Input: text = "cbacdb"

Output: "acdb"

Example 2:

Input: text = "bcacbac"

Output: "abc"

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result