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. QT中phonon的安装和使用

    http://write.blog.csdn.net/postedit Phonon严格来说其实非为Qt的library,Phonon原本就是KDE 4的开放原始码多媒体API,後来与Qt合并与开发, ...

  2. 平衡二叉树--java

    package com.test.tree; /** * 带有平衡条件的二叉查找树 * */ public class AVLBinarySearchTree<T extends Compara ...

  3. 177. Nth Highest Salary

    问题描述 解决方案 CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT BEGIN declare number int; set numbe ...

  4. tortoisegit推送ssh-key需要输入用户信息

    修改了测试代码,却在提交代码时候又跳出来请输入用户名和密码, 后来发现,github push有两种方式,ssh方式和https方式.而https方式是不同的,具体来说,就是url信息的不同,实际的验 ...

  5. 改善Chrome在Windows下的中文字体效果

    方法一:摘自卡饭论坛 chrome://flags/#disable-direct-write 启用 chrome://flags/#num-raster-threads 改为 1 chrome:// ...

  6. ural 2017 Best of a bad lot

    2017. Best of a bad lot Time limit: 1.0 secondMemory limit: 64 MB A cruise liner hasn’t moved away f ...

  7. Python学习之路day3-字符编码与转码

    一.基础概念 字符与字节 字符是相对于人类而言的可识别的符号标识,是一种人类语言,如中文.英文.拉丁文甚至甲骨文.梵语等等.    字节是计算机内部识别可用的符号标识(0和1组成的二进制串,机器语言) ...

  8. Codeforces Round #276 (Div. 2)A. Factory(数论)

    这道题可以暴力的一直按要求的方法去做,做1000000次还不能整除m就认为永远不能整除m了(m不超过100000,循环1000000次比较安全了已经).这种方法可以AC. 下面深入的分析一下到底循环多 ...

  9. C++ 静态常量

    #include<iostream> #include<stdexcept> #include <map> using namespace std; class n ...

  10. CodeForces - 154C:Double Profiles (hash+排序)

    You have been offered a job in a company developing a large social network. Your first task is conne ...