[Swift]LeetCode1081. 不同字符的最小子序列 | Smallest Subsequence of Distinct Characters

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
➤微信公众号:山青咏芝(shanqingyongzhi)
➤博客园地址:山青咏芝(https://www.cnblogs.com/strengthen/
➤GitHub地址:https://github.com/strengthen/LeetCode
➤原文地址:https://www.cnblogs.com/strengthen/p/10993157.html  
➤如果链接不是山青咏芝的博客园地址,则可能是爬取作者的文章。
➤原文已修改更新!强烈建议点击原文地址阅读!支持作者!支持原创!
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

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.

返回字符串 text 中按字典序排列最小的子序列,该子序列包含 text 中所有不同字符一次。 

示例 1:

输入:"cdadabcc"
输出:"adbc"

示例 2:

输入:"abcd"
输出:"abcd"

示例 3:

输入:"ecbacba"
输出:"eacb"

示例 4:

输入:"leetcode"
输出:"letcod" 

提示:

  1. 1 <= text.length <= 1000
  2. text 由小写英文字母组成

 

上一篇:C语言的简单使用(九、字符串查找经典模型)


下一篇:c#学习<一> 基础知识