You are given two strings s and t of the same length and an integer maxCost.

You want to change s to t. Changing the ith character of s to ith character of t costs |s[i] - t[i]| (i.e., the absolute difference between the ASCII values of the characters).

Return the maximum length of a substring of s that can be changed to be the same as the corresponding substring of t with a cost less than or equal to maxCost. If there is no substring from s that can be changed to its corresponding substring from t, return 0.

&nbsp;
Example 1:

Input: s = "abcd", t = "bcdf", maxCost = 3
Output: 3
Explanation: "abc" of s can change to "bcd".
That costs 3, so the maximum length is 3.


Example 2:

Input: s = "abcd", t = "cdef", maxCost = 3
Output: 1
Explanation: Each character in s costs 2 to change to character in t,  so the maximum length is 1.


Example 3:

Input: s = "abcd", t = "acde", maxCost = 0
Output: 1
Explanation: You cannot make any change, so the maximum length is 1.


&nbsp;
Constraints:


	1 &lt;= s.length &lt;= 105
	t.length == s.length
	0 &lt;= maxCost &lt;= 106
	s and t consist of only lowercase English letters.


class Solution(object):
    def equalSubstring(self, s, t, maxCost):
        """
        :type s: str
        :type t: str
        :type maxCost: int
        :rtype: int
        """
        
        
        
        
        best = 0
        
        windowCost = 0
        l = 0
        for r in range(len(s)):
            
            windowCost += abs(ord(s[r]) - ord(t[r]))
            
            while windowCost > maxCost:
                
                windowCost -= abs(ord(s[l]) - ord(t[l]))
                l+=1
                
            best = max(best,r-l+1)
            
        return best
                
            
            
class Solution {
    public int equalSubstring(String s, String t, int maxCost) {
        int ans =0;
        int tempcost =0;
        int l =0 ;
        int r= 0 ;
        for(;r!=s.length();r++){
            tempcost += Math.abs(s.charAt(r)-t.charAt(r));
            while(tempcost>maxCost){
                tempcost -= Math.abs(s.charAt(l)-t.charAt(l));
                l++;
            }
            ans =Math.max(ans,r+1-l);
        }
        return ans;
    }
}
class Solution {
public:
    int equalSubstring(string s, string t, int maxCost) {
        int l = 0, r = 0, currCost = 0, n = s.length(), maxLen = 0;

        while(r < n) {
            currCost += abs(s[r] - t[r]);
            r++;

            while(currCost > maxCost) {
                currCost -= abs(s[l] - t[l]);
                l++;
            }

            maxLen = max(r - l, maxLen);
        }

        return maxLen;
    }
};
var equalSubstring = function(s, t, maxCost) {
    let dp = [], ans = 0;

    for (let i = 0, j = 0, k = 0; i < s.length; i++) {
        // overlay
        k += dp[i] = abs(s[i], t[i]);
        
        // non first
        if (k > maxCost) {
            k -= dp[j], j++;
            continue;
        }
        
        // eligible
        ans++;
    }

    return ans;

    // get abs value
    function abs(a, b) {
        return Math.abs(a.charCodeAt(0) - b.charCodeAt(0));
    }
};
Get Equal Substrings Within Budget