Two Pointer | Simple Solution | Time O(n), Space O(n)
```\n    public int equalSubstring(String s, String t, int maxCost) {\n        int l = s.length();\n        int[] nums = new int[l];\n        for(int i=0; i<s.l
```\n    public int equalSubstring(String s, String t, int maxCost) {\n        int l = s.length();\n        int[] nums = new int[l];\n        for(int i=0; i<s.length(); ++i) {\n            nums[i] = Math.abs(s.charAt(i) - t.charAt(i));\n        }\n        int len = 0;\n        int sum = 0;\n        for(int i=0, j=0; i<l; ++i) {\n            sum += nums[i];\n            while (j<=i && sum > maxCost) {\n                sum -= nums[j++];\n            }\n            len = Math.max(len, i-j+1);\n        }\n        return len;\n    }
[]