Binary Search + sliding window
\nbool fun(int len,string s,string t,int maxcost,int n)\n    {\n        int temp=0,cost=0;\n        for(int i=0;i<n;i++)\n        {\n            cost+=(abs((s[i
```\nbool fun(int len,string s,string t,int maxcost,int n)\n    {\n        int temp=0,cost=0;\n        for(int i=0;i<n;i++)\n        {\n            cost+=(abs((s[i]-\'a\')-(t[i]-\'a\')));\n        }\n        for(int i=n;i<len;i++)\n        {\n            if(cost<=maxcost) return(1);\n            cost+=(abs((s[i]-\'a\')-(t[i]-\'a\')));\n            cost-=(abs((s[i-n]-\'a\')-(t[i-n]-\'a\')));\n        }\n        if(cost<=maxcost) return(1);\n        return(0);\n    }\n    \n    \n    \n    int equalSubstring(string s, string t, int maxCost)\n    {\n        int len1=s.size();\n        int lo=0,hi=len1;\n        int ans=0;\n        while(hi>=lo)\n        {\n            int mid=(lo+hi)/2;\n            if(fun(len1,s,t,maxCost,mid)) \n            {\n                ans=mid;\n                lo=mid+1;\n            }\n            else hi=mid-1;\n        }\n        return(ans);\n    }\n```
['Sliding Window', 'Binary Tree']