Java || Sliding Window || T.C - O(n) S.C - O(1)
\n    public int equalSubstring(String s, String t, int maxCost) {\n\n\t\tint len = s.length(), max = 0, idx1 = -1, idx2 = 0, cost = 0;\n\n\t\twhile (idx2 < len
\n    public int equalSubstring(String s, String t, int maxCost) {\n\n\t\tint len = s.length(), max = 0, idx1 = -1, idx2 = 0, cost = 0;\n\n\t\twhile (idx2 < len) {\n\n\t\t\twhile (idx2 < len) {\n\t\t\t\tcost += Math.abs(s.charAt(idx2) - t.charAt(idx2));\n\t\t\t\tif (cost <= maxCost) {\n\t\t\t\t\tif (idx2 - idx1 > max)\n\t\t\t\t\t\tmax = idx2 - idx1;\n\t\t\t\t\tidx2++;\n\t\t\t\t} else {\n\t\t\t\t\tidx2++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\twhile (idx1 < idx2) {\n\t\t\t\tidx1++;\n\t\t\t\tcost -= Math.abs(s.charAt(idx1) - t.charAt(idx1));\n\t\t\t\tif (cost <= maxCost)\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t}\n\n\t\treturn max;\n\t}
[]