How to get the smallest in lexicographical order?

后端 未结 6 1777
抹茶落季
抹茶落季 2021-02-05 07:43

I am doing a leetcode exercise

https://leetcode.com/problems/remove-duplicate-letters/

The question is:

# Given a string which contains only lowe         


        
6条回答
  •  太阳男子
    2021-02-05 08:26

    the smallest in lexicographical order - your answer should be a subsequence of initial string, containing one instance of every char.
    If there are many such subsequences possible (bca, bac, cab, abc for the first example), return the smallest one, comparing them as strings (consider string order in vocabulary).

    why Given "bcabc" then the answer would be "acdb"
    You confused two different examples

提交回复
热议问题