Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Get Equal Substrings Within Budget

Strings s and t have equal length. Changing s[i] to t[i] costs |s[i] - t[i]| (difference of character codes). Print the maximum length of a substring of s that can be changed into the corresponding substring of t with total cost at most maxCost.

Constraints

1 <= len(s) = len(t) <= 10^5 0 <= maxCost <= 10^6

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.