Karleb
Posted on
#1208. Get Equal Substrings Within Budget
/** * @param {string} s * @param {string} t * @param {number} maxCost * @return {number} */varequalSubstring=function(s,t,maxCost){letn=s.length,start=0,currCost=0,maxLen=0for(letend=0;end<n;end++){currCost+=Math.abs(s.charCodeAt(end)-t.charCodeAt(end))while(currCost>maxCost){currCost-=Math.abs(s.charCodeAt(start)-t.charCodeAt(start))start++}maxLen=Math.max(maxLen,end-start+1)}returnmaxLen};
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse