Practice Replace Question Marks in String to Minimize Its Value
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Replace Question Marks in String to Minimize Its Value
Problem Statement
Given s containing lowercase letters and question marks, replace every question mark with a lowercase letter. The cost of a position is the number of equal characters before it; the value of the string is the sum of these costs. For example, aab has value 0 + 1 + 0 = 1. Return a replacement string with minimum value, breaking ties by choosing the lexicographically smallest string.
Source: Replace Question Marks in String to Minimize Its Value on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "???"
"abc"
# Example 2
s = "a?a?"
"abac"
Constraints
Related LeetCode Problems
Practice more problems similar to Replace Question Marks in String to Minimize Its Value.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.