3106. Lexicographically Smallest String After Operations With Constraint
You are given a string
sand an integerk.Define a function
distance(s1, s2)between two stringss1ands2of the same lengthnas:
- The sum of the minimum distance between
s1[i]ands2[i]when the characters from'a'to'z'are placed in a cyclic order, for alliin the range[0, n - 1].For example,
distance("ab", "cd") == 4, anddistance("a", "z") == 1.You can change any letter of
sto any other lowercase English letter, any number of times.Return a string denoting the lexicographically smallest string
tyou can get after some changes, such thatdistance(s, t) <= k.
1 | class Solution { |