Skip to content

3170. Lexicographically Minimum String After Removing Stars #1778

Answered by mah-shamim
mah-shamim asked this question in Q&A
Discussion options

You must be logged in to vote

We need to remove all '' characters from the string while ensuring that each '' is removed along with the smallest non-'*' character to its left. If there are multiple smallest characters, we remove the rightmost one to ensure the resulting string is lexicographically smallest.

Approach

  1. Problem Analysis: The problem requires processing each '' in the string by removing it along with the smallest character to its left. The key challenge is efficiently finding the smallest character to the left of each '' and ensuring the solution is optimal for large input sizes (up to 10^5 characters).

  2. Intuition: The lexicographically smallest string is achieved by preserving as many leftmost characte…

Replies: 1 comment 2 replies

Comment options

mah-shamim
Jun 7, 2025
Maintainer Author

You must be logged in to vote
2 replies
@kovatz
Comment options

kovatz Jun 7, 2025
Collaborator

@mah-shamim
Comment options

mah-shamim Jun 7, 2025
Maintainer Author

Answer selected by kovatz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested medium Difficulty
2 participants