作者:我爱超人宝宝 | 来源:互联网 | 2023-10-12 14:54
1208. 尽可能使字符串相等
int[] num = new int[s.length()];
for(int i = 0; i
num[i] = Math.abs(s.charAt(i) - t.charAt(i));
}
int left = 0, right = 0;
int sum = 0;
int ans = 0;
while(right
sum += num[right];
while(sum > maxCost) {注意循环
sum -= num[left];
left++;
}
ans = Math.max(ans, right - left + 1);
right++;别忘了
}
return ans;