[Swift] LeetCode1081 a minimal sequence of different characters |. Smallest Subsequence of Distinct Characters

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
➤ micro-channel public number: Shan Wing Chi ( shanqingyongzhi)
➤ blog Park address: San-ching Wing Chi ( https://www.cnblogs.com/strengthen/ )
➤GitHub address: https://github.com/strengthen/LeetCode
➤ original address: HTTPS: // the WWW. cnblogs.com/strengthen/p/10993157.html  
➤ If the link is not the blog Chi Wing Shan Park address, it may be crawling author of the article.
➤ text has been modified update! Click strongly recommended that the original address read! Support authors! Support the original!
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

Return the lexicographically smallest subsequence of text that contains all the distinct characters of textexactly once. 

Example 1:

Input: "cdadabcc"
Output: "adbc"

Example 2:

Input: "abcd"
Output: "abcd"

Example 3:

Input: "ecbacba"
Output: "eacb"

Example 4:

Input: "leetcode"
Output: "letcod" 

Note:

  1. 1 <= text.length <= 1000
  2. text consists of lowercase English letters.

Returns a string  text press lexicographic order minimal sequence, which sequence comprises  text all the different character at a time. 

Example 1:

Enter: "cdadabcc" 
Output: "adbc"

Example 2:

Enter: "abcd" 
Output: "abcd"

Example 3:

Enter: "ecbacba" 
Output: "eacb"

Example 4:

Enter: "leetcode" 
Output: "letcod" 

prompt:

  1. 1 <= text.length <= 1000
  2. text English lowercase letters

 

Guess you like

Origin www.cnblogs.com/strengthen/p/10993157.html