To solve this problem, you'll have to open it on the computer

Remove Duplicate Letters

Stacks
medium
Score: 20

Given a string s, remove duplicate letters so that every letter appears once and only once.

You must make sure your result is the smallest in lexicographical order among all possible results.

Input Format:

First Parameter - String s

Output Format:

Return a string that is the smallest in lexicographical order among all possible results

Example 1:

Input: bcabc
Output: abc

Example 2:

Input: devsnest
Output: devnst

Constraints:-

  • 1 <= length of string <= 104
  • string consists of lowercase English letters.
  • Expected Time Complexity:- O(n)
  • Expected Space Complexity: O(n)
Submit code to see the your result here