[Java/C++/Python] Sliding Window
Intuition\nChange the input of string s and t into an array of difference.\nThen it\'s a standard sliding window problem.\n\n\n## Complexity\nTime O(N) for one 
## **Intuition**\nChange the input of string `s` and `t` into an array of difference.\nThen it\'s a standard sliding window problem.\n<br>\n\n## **Complexity**\nTime `O(N)` for one pass\nSpace `O(1)`\n<br>\n\n**Java:**\n```java\n    public int equalSubstring(String s, String t, int k) {\n        int n = s.length(), i = 0, j;\n        for (j = 0; j < n; ++j) {\n            k -= Math.abs(s.charAt(j) - t.charAt(j));\n            if (k < 0) {\n                k += Math.abs(s.charAt(i) - t.charAt(i));\n                ++i;\n            }\n        }\n        return j - i;\n    }\n```\n\n**C++:**\n```cpp\n    int equalSubstring(string s, string t, int k) {\n        int n = s.length(), i = 0, j;\n        for (j = 0; j < n; ++j) {\n            if ((k -= abs(s[j] - t[j])) < 0)\n                k += abs(s[i] - t[i++]);\n        }\n        return j - i;\n    }\n```\n\n**Python:**\n```python\n    def equalSubstring(self, s, t, cost):\n        i = 0\n        for j in xrange(len(s)):\n            cost -= abs(ord(s[j]) - ord(t[j]))\n            if cost < 0:\n                cost += abs(ord(s[i]) - ord(t[i]))\n                i += 1\n        return j - i + 1\n```\n
[]