- What kind of structure can we use to preserve an
ascending order? - Monotonic stack
- However, if a char
won't appear again, we cannot just pop it. So we need an
- Also, if we’ve popped every char that we can pop in the stack, what if the
charis aleady in the
- If it’s been in stack, which means those chars in the stack has already been in
lexicographicalorder. There is no need to pop any chars out and add an already
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: s = "bcabc"