java.lang.Object
g1001_1100.s1081_smallest_subsequence_of_distinct_characters.Solution

public class Solution extends Object
1081 - Smallest Subsequence of Distinct Characters.<p>Medium</p> <p>Given a string <code>s</code>, return <em>the lexicographically smallest subsequence of</em> <code>s</code> <em>that contains all the distinct characters of</em> <code>s</code> <em>exactly once</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;bcabc&rdquo;</p> <p><strong>Output:</strong> &ldquo;abc&rdquo;</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;cbacdcbc&rdquo;</p> <p><strong>Output:</strong> &ldquo;acdb&rdquo;</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 1000</code></li> <li><code>s</code> consists of lowercase English letters.</li> </ul> <p><strong>Note:</strong> This question is the same as 316: <a href="https://leetcode.com/problems/remove-duplicate-letters/" target="_top">https://leetcode.com/problems/remove-duplicate-letters/</a></p>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • smallestSubsequence

      public String smallestSubsequence(String s)