Search
⌘K

Leetcode 3081. Replace Question Marks in String to Minimize Its Value

Given a string s with '?' wildcards, replace each '?' by a lowercase letter to minimize the total "value" — defined as the sum over positions of how many identical characters appeared before that position (i.e., penalizing repeated earlier occurrences). If multiple completions achieve the minimum value, return the lexicographically smallest one; n ≤ 1e5.


Question Timeline

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

Comments

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