gary@interview:~/interview/coding/1208-get-equal-s….md$
$ cat ./coding/1208-get-equal-substrings-within-budget.md
[Coding]

1208. Get Equal Substrings Within Budget

────────────────────────────────────────────────────────────

1208. Get Equal Substrings Within Budget

class Solution:
    def equalSubstring(self, s: str, t: str, maxCost: int) -> int:
        maxLen = 0
        currCost = 0
        start = 0

        for i in range(len(s)):
            currCost += abs(ord(s[i]) - ord(t[i]))

            while currCost > maxCost:
                currCost -= abs(ord(s[start]) - ord(t[start]))
                start += 1
            
            maxLen = max(maxLen, i - start + 1)
        
        return maxLen
--tags#Sliding Window
$ ls ./coding/ | grep -v 1208-get-equal-substrings-within-budget
265. Paint House II256. Paint House143. Reorder List1762. Buildings With an Ocean View
← cd ../codingcd ~