C++: Sliding Window || O(n) Solution
```\nclass Solution {\npublic:\n    int equalSubstring(string s, string t, int maxCost) {\n        int n = s.length();\n        int left=0,right=0,ans=0,cost=0;
```\nclass Solution {\npublic:\n    int equalSubstring(string s, string t, int maxCost) {\n        int n = s.length();\n        int left=0,right=0,ans=0,cost=0;\n        while(right<n){\n            cost= cost + abs(s[right]-t[right]);\n            while(cost>maxCost){\n                cost= cost - abs(s[left]-t[left]);\n                left++;\n            }\n            ans = max(ans,right-left+1);\n            right++;\n        }\n        return ans;\n    }\n};
[]