Short code. One pass. Beats 100%. 
IntuitionMaintain the maximum result found up to the ith charactor.ApproachWhen adding the cost of changing the ith charactor, check the accumulated cost, if sm
# Intuition
Maintain the maximum result found up to the ith charactor. 

# Approach
When adding the cost of changing the ith charactor, check the accumulated cost, if small enough, increase result by 1; otherwise, keep the result unchanged, and remove the cost from the first of the current window (the (i-res)th charactor). 

# Complexity
- Time complexity:
$$O(n)$$

- Space complexity:
$$O(1)$$

# Code
```cpp []
class Solution {
public:
    int equalSubstring(string s, string t, int maxCost) {
        int res = 0;
        int accum = 0;
        for (int i=0; i<s.size(); i++) {
            accum += abs(s[i]-t[i]);
            if (accum<=maxCost) {
                res++;
            } else {
                accum -= abs(s[i-res]-t[i-res]);
            }
        }
        return res;
    }
};
```
['C++']