You're given a string containing lowercase letters, and your mission is to create the lexicographically smallest string possible while ensuring each letter appears exactly once.
This is a classic greedy problem that requires strategic thinking! You need to remove duplicate letters, but not just any removal will do - you must produce the smallest possible result when compared alphabetically.
Example: Given "bcabc", you could form "bca", "cab", or "abc" - but "abc" is lexicographically smallest!
Think of it like arranging books on a shelf - you want the alphabetically earliest arrangement possible using each book exactly once.
Input & Output
Constraints
- 1 โค s.length โค 104
- s consists of lowercase English letters
- Each character must appear exactly once in the result