Install our extension to search inside any video instantly.

Daily Leetcode : Jul 19, 2026 - 1081. Smallest Subsequence of Distinct Characters

Added:
261 views12likes18:04AlgorithmistOriginal Release: 2026-07-19

To find the lexicographically smallest subsequence containing all distinct characters of a string, use a greedy approach: iterate through sorted distinct characters, and for each character, select the first occurrence that still allows all remaining characters to appear later in the string; this ensures the result is both lexicographically smallest and contains all distinct characters exactly once.