fork download
  1. def minimize_string_value(s):
  2. s = list(s)
  3. n = len(s)
  4. for i in range(n):
  5. if s[i] == '7':
  6. # Choose the smallest possible character that minimizes the cost
  7. # We can choose 'a' as it is the lexicographically smallest
  8. s[i] = 'a'
  9. return ''.join(s)
  10.  
  11. # Example usage:
  12. print(minimize_string_value("???")) # Output: "abc"
  13. print(minimize_string_value("n>n")) # Output: "abc"
Success #stdin #stdout 0.13s 14084KB
stdin
Standard input is empty
stdout
???
n>n