Remove Duplicate Letters for Lexicographically Smallest Result

Asked at ByteDance · Coding Questions · Difficulty: Medium · Last asked Jun 24, 2026

Given a string `s` of lowercase English letters, delete characters so that every distinct letter of `s` appears exactly once, keeping the remaining characters in their original relative order. Return the lexicographically smallest string that can be obtained this way.

Loading the problem…