title: How to get the smallest in lexicographical order?
body: <p>I am doing a leetcode exercise</p>
  
  <p><a href="https://leetcode.com/problems/remove-duplicate-letters/" rel="noreferrer">https://leetcode.com/problems/remove-duplicate-letters/</a></p>
  
  <p>The question is:</p>
  
  <pre><code># 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:
  # Given "bcabc"
  # Return "abc"
  #
  # Given "cbacdcbc"
  # Return "acdb"
  </code></pre>
  
  <p>I am not quite sure about <code>what is the smallest in lexicographical order</code> and why Given "cbacdcbc" then the answer would be "acdb"</p>
  
  <p>Thanks for the answer in advance :)</p>