human
Solve in Python:
Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.
 
Example 1:
 
 
Input: "bcabc"
Output: "abc"
 
 
Example 2:
 
 
Input: "cbacdcbc"
Output: "acdb"
assistant
#Here is the Python code you requested.

class Solution:
     def removeDuplicateLetters(self, s):
         if not s:
             return ""
         
         res = ''
         sorted_set = sorted(set(s))
         
         for c in sorted_set:
             sub_s = s[s.index(c):]
             if set(s) == set(sub_s):
                 return c + self.removeDuplicateLetters(sub_s.replace(c, ''))
         
                 
         return res