Problem
You get two strings s and t of the same length and an integer max_cost. Changing s[i] into t[i] costs abs(ord(s[i]) - ord(t[i])), the distance between their character codes. Return the length of the longest substring of `s` that can be changed to the matching substring of `t` with a total cost of at most `max_cost`.
Example 1
- Input
- s = "abcd", t = "bcdf", max_cost = 3
- Output
- 3
- Why
- "abc" → "bcd" costs 3
Example 2
- Input
- s = "abcd", t = "cdef", max_cost = 3
- Output
- 1
Example 3
- Input
- s = "abcd", t = "acde", max_cost = 0
- Output
- 1
- Why
- "a" already matches
Constraints
1 <= s.length <= 10^5t.length == s.length0 <= max_cost <= 10^6s and t consist of lowercase English letters.