SalesforceOA #37
Same Substring
估计中等可在线判题
考点(AI 标注)双指针滑窗
s and t have equal length and contain only lowercase letters. The cost of changing s[i] to t[i] is the absolute difference of their ASCII codes. Find a contiguous interval whose total position-by-position conversion cost is ≤K, and return the maximum interval length; return 0 if no non-empty interval qualifies.
输入格式
The input is a JSON array [s,t,K]. The original has no numeric bounds; this site adds 0≤|s|=|t|≤200000, 0≤K≤10^9; the total encoded input is ≤401000 bytes.
输出格式
Output one integer answer.
样例 1
输入:
["abcd","bcdf",3]
输出:
3
样例 2
输入:
["az","za",0]
输出:
0
样例 3
输入:
["","",0]
输出:
0
样例说明
The outputs of the three public examples are, in order: 3; 0; 0. They have been checked by independent enumeration or direct simulation.