Tap here to switch tabs
Problem
Submissions

Problem: Get Equal Substrings Within Budget

med
30 min
Try to solve the Get Equal Substrings Within Budget problem.

Statement

You are given two strings s and t of the same length, along with an integer maxCost.

Changing the character s[i] to t[i] costs ∣|s[i] −- t[i]∣|, which represents the absolute difference between their ASCII values.

Return the maximum length of a substring of s that can be transformed to match the corresponding substring of t with a total cost less than or equal to maxCost. If no such substring can be transformed within the given budget, return 00.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • t.length ==== s.length

  • 0≤0 \leq maxCost ≤106\leq 10^6

  • s and t consist of only lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Get Equal Substrings Within Budget

med
30 min
Try to solve the Get Equal Substrings Within Budget problem.

Statement

You are given two strings s and t of the same length, along with an integer maxCost.

Changing the character s[i] to t[i] costs ∣|s[i] −- t[i]∣|, which represents the absolute difference between their ASCII values.

Return the maximum length of a substring of s that can be transformed to match the corresponding substring of t with a total cost less than or equal to maxCost. If no such substring can be transformed within the given budget, return 00.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • t.length ==== s.length

  • 0≤0 \leq maxCost ≤106\leq 10^6

  • s and t consist of only lowercase English letters.