Search
⌘K

Leetcode 3170. Lexicographically Minimum String After Removing Stars

Given a string of lowercase letters and '*' where each operation deletes the leftmost '*' and the lexicographically smallest non-'*' character to its left, compute the lexicographically smallest resulting string after all '*' are removed. The core challenge is greedily selecting and removing the minimal preceding characters while preserving order, which calls for an ordered multiset/priority structure or an amortized stack-based approach to achieve optimal performance for n up to 1e5.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Your account is free and you can post anonymously if you choose.