Java Sliding Window
\nclass Solution {\n    public int equalSubstring(String s, String t, int maxCost) {\n        int l = 0;\n        int r = 0;\n        int max = 0;\n        whil
```\nclass Solution {\n    public int equalSubstring(String s, String t, int maxCost) {\n        int l = 0;\n        int r = 0;\n        int max = 0;\n        while (r < s.length()) {\n            maxCost -= Math.abs(s.charAt(r) - t.charAt(r));\n            r++;\n            if (maxCost >= 0) {\n                max = Math.max(max, r - l);\n            }\n            while (maxCost < 0) {\n                maxCost += Math.abs(s.charAt(l) - t.charAt(l));\n                l++;\n            }\n        }\n        return max;\n    }\n}\n```
[]