You are given two strings `s` and `t` of the same length and an integer `maxCost`. Changing `s[i]` into `t[i]` costs `|s[i] - t[i]|` (the difference of their ASCII codes). Return the maximum length of a substring of `s` that can be changed into the matching substring of `t` with total cost at most `maxCost`, or `0` if none can.
You are given two strings s and t of the same length and an integer maxCost. Changing s[i] into t[i] costs |s[i] - t[i]| (the difference of their ASCII codes). Return the maximum length of a substring of s that can be changed into the matching substring of t with total cost at most maxCost, or 0 if none can.
Example 1:
Input: {"s":"abcd","t":"bcdf","maxCost":3}
Output: 3
Constraints:
1≤s.length≤105
t.length=s.length
0≤maxCost≤106
s and t consist of lowercase English letters.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s":"abcd","t":"bcdf","maxCost":3}
Each column i costs |s[i] - t[i]|. Find the widest run of columns whose costs add up to at most 3.