[Python3] Sliding Window - Two ways to implement - Easy to Understand
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def equalSubstring(self, s: str, t: str, maxCost: int) -> int:\n        res = 0\n        i = j = cost = 0\n        while j < len(s):\n            cost += abs(ord(s[j]) - ord(t[j]))\n            while cost > maxCost:\n                cost -= abs(ord(s[i]) - ord(t[i]))\n                i += 1\n            res = max(res, j - i + 1)\n            j += 1\n        return res\n```\n\n\n```\nclass Solution:\n    def equalSubstring(self, s: str, t: str, maxCost: int) -> int:\n        res = 0\n        i = j = cost = 0\n        while j < len(s):\n            cost += abs(ord(s[j]) - ord(t[j]))\n            if cost > maxCost:\n                cost -= abs(ord(s[i]) - ord(t[i]))\n                i += 1\n            j += 1\n        return j - i\n```
['Sliding Window', 'Python3']