Get Min Cost Data
Problem Overview
- Replace all '?' in a lowercase string to minimize total cost, where an index’s cost equals the number of earlier indices with the same letter.
- Return the resulting string; if multiple reach the minimum cost, choose the lexicographically smallest; 1 ≤ |data| ≤ 1e5 and at least one '?'.
- Context: data interpolation model with 26 classifications (a–z).
- Source: Amazon interviews; a coding interview problem and common interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
