C# Solution | Time: O(n), Memory: O(1) | Easy to understand, Sliding window
C#\npublic class Solution {\n    public int EqualSubstring(string s, string t, int maxCost) {\n        int cost = 0, start = 0, end = 0;\n        while (end < s
```C#\npublic class Solution {\n    public int EqualSubstring(string s, string t, int maxCost) {\n        int cost = 0, start = 0, end = 0;\n        while (end < s.Length) {\n            cost += Math.Abs(s[end] - t[end]);\n            if (cost > maxCost) {\n                cost -= Math.Abs(s[start] - t[start]);\n                start++;\n            }\n            \n            end++;\n        }\n        \n        return end - start;\n    }\n}\n```
['Sliding Window']