3361. Shift Distance Between Two Strings
You are given two strings
s
andt
of the same length, and two integer arraysnextCost
andpreviousCost
.In one operation, you can pick any index
i
ofs
, and perform either one of the following actions:
- Shift
s[i]
to the next letter in the alphabet. Ifs[i] == 'z'
, you should replace it with'a'
. This operation costsnextCost[j]
wherej
is the index ofs[i]
in the alphabet.- Shift
s[i]
to the previous letter in the alphabet. Ifs[i] == 'a'
, you should replace it with'z'
. This operation costspreviousCost[j]
wherej
is the index ofs[i]
in the alphabet.The shift distance is the minimum total cost of operations required to transform
s
intot
.Return the shift distance from
s
tot
.