Python 3 solution (sliding window)
Code\npy\nclass Solution:\n    def equalSubstring(self, s: str, t: str, maxCost: int) -> int:\n        costs = [abs(ord(a) - ord(b)) for a, b in zip(s, t)]\n   
# Code\n```py\nclass Solution:\n    def equalSubstring(self, s: str, t: str, maxCost: int) -> int:\n        costs = [abs(ord(a) - ord(b)) for a, b in zip(s, t)]\n        left = result = total = 0\n        for right in range(len(costs)):\n            total += costs[right]\n            while left <= right and total > maxCost:\n                total -= costs[left]\n                left += 1\n            if result < (new := right - left + 1):\n                result = new\n        return result        \n```
['Python3']