Imagine you're a text editor developer working on a smart autocorrect feature. You have two strings: s (the current text) and t (the target text), both of the same length. You want to transform s into t, but each character change has a cost.
The cost of changing the i-th character of s to the i-th character of t is |s[i] - t[i]| (the absolute difference between their ASCII values). For example, changing 'a' to 'c' costs |97 - 99| = 2.
Given a budget of maxCost, find the maximum length of a contiguous substring that you can completely transform from s to match the corresponding substring in t.
Think of it as finding the longest segment of text you can autocorrect within your computational budget!
Input & Output
Constraints
- 1 โค s.length, t.length โค 105
- 0 โค maxCost โค 106
- s and t consist of only lowercase English letters
- s.length == t.length