public class Solution {
public int CharacterReplacement(string s, int k) {
int len = s.Length;
int[] count = new int[];
int start = , maxCount = , maxLength = ;
for (int end = ; end < len; end++)
{
maxCount = Math.Max(maxCount, ++count[s[end] - 'A']);
while (end - start + - maxCount > k)
{
count[s[start] - 'A']--;
start++;
}
maxLength = Math.Max(maxLength, end - start + );
}
return maxLength;
}
}

https://leetcode.com/problems/longest-repeating-character-replacement/#/description

leetcode424的更多相关文章

  1. [Swift]LeetCode424. 替换后的最长重复字符 | Longest Repeating Character Replacement

    Given a string that consists of only uppercase English letters, you can replace any letter in the st ...

  2. leetcode424 Longest Repeating Character Replacement

    """ Given a string s that consists of only uppercase English letters, you can perform ...

随机推荐

  1. Python之异常总结

    一.异常错误 a.语法错误 错误一: if 错误二: def text: pass 错误三: print(sjds b.逻辑错误 #用户输入不完整(比如输入为空)或者输入非法(输入不是数字) num= ...

  2. MySQL索引分析

    索引的出现解决数据量上升导致查询越来越慢的问题,优化数据的查询,提高查询的速度. 索引 定义: 通过各种数据结构实现的值到行位置的映射.快速定位与访问特定的数据. 作用: 提高访问速度 实现主键.唯一 ...

  3. BW 转换字符空格问题

    早上忙了我一早上,以前写的一个季度判断的问题, 首先是调试,不断的调试DTP.让我头晕眼花. 首先关于空格问题,我自我批评,愚蠢的定义成STRING 类型,然后相互加减出现问题.应该定义成内部的日期格 ...

  4. 14 Python 装饰器

    装饰器 装饰器其实就是一个以函数作为参数并返回一个替换函数的可执行函数.让我们从简单的开始,直到能写出实用的装饰器. def outer(some_func): def inner(): print ...

  5. LeetCode OJ:Serialize and Deserialize Binary Tree(对树序列化以及解序列化)

    Serialization is the process of converting a data structure or object into a sequence of bits so tha ...

  6. 2018.8.11E-mail

    1发送附件 Attached please find the XXX  for your review and comment. Outlook的附件最好不超过10M,文件要用英语命名,视频音频要压缩 ...

  7. innoDB 下主键的思考

    主键 表中每一行都应该有可以唯一标识自己的一列(或一组列). 一个顾客可以使用顾客编号列,而订单可以使用订单ID,雇员可以使用雇员ID 或 雇员社会保险号. 主键(primary key) 一列(或一 ...

  8. dbca 快速健建库

    [oracle@e0946877f272 ~]$ dbca -silent -createDatabase -templateName $ORACLE_HOME/assistants/dbca/tem ...

  9. grep---Linux下文本处理五大神器之五

    转自:http://www.cnblogs.com/dong008259/archive/2011/12/12/2285264.html grep是linux中很常用的一个命令,主要功能就是进行字符串 ...

  10. poj3171 Cleaning Shifts[DP]

    https://vjudge.net/problem/POJ-3171.(有价值的区间全覆盖问题) (lyd例题)朴素DP很好想,$f[i]$表示将右端点从小到大排序后从$L$(要求覆盖的大区间)到第 ...