/**
* @param {string} s
* @param {string} t
* @param {number} maxCost
* @return {number}
*/
var equalSubstring = function(s, t, maxCost) {
let n = s.length, start = 0, currCost = 0, maxLen = 0
for (let end = 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)
}
return maxLen
};
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)