leetcode424
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的更多相关文章
- [Swift]LeetCode424. 替换后的最长重复字符 | Longest Repeating Character Replacement
Given a string that consists of only uppercase English letters, you can replace any letter in the st ...
- leetcode424 Longest Repeating Character Replacement
""" Given a string s that consists of only uppercase English letters, you can perform ...
随机推荐
- ComboBoxStyle和ToggleButton
<Style x:Key="ComboBoxStyle" TargetType="{x:Type ComboBox}"> <Setter ...
- 《Advanced Bash-scripting Guide》学习(十三):引用变量的两个例子
本文所选的例子来自于<Advanced Bash-scripting Gudie>一书,译者 杨春敏 黄毅 例1. 使用""可以防止单词分割,将变量看成一个整体,没有& ...
- poj1463 树形dp
树形dp裸题,不过输入是真的恶心,要字符串读入考虑数字大于等于10的情况 dp[i][j]表示i的子树在j状态的最小的边集覆盖,j为0表示不选当前结点,1表示选 转移方程(u->x是u的所有子节 ...
- Mac的搜狗输入法和QQ输入法加入⌘⌥⌃⇧自定义短语
搜狗输入法(Mac):http://pinyin.sogou.com/mac/ 创建名为『搜狗输入法自定义短语.ini』的文本文件(建议用Sublime Text),内容如下,然后偏好设置的自定义短语 ...
- Mac终端ls显示文件名为彩色
原理: ls -G 可显示彩色文件名. 在终端输入: nano ~/.bash_profile 辑器.bash_profile文件,粘贴下面内容: alias cls='tput reset' ali ...
- python3.x学习笔记2018-02-05更新
前言:python3.x部分学习笔记,有意交流学习者可加wechat:YWNlODAyMzU5MTEzMTQ=.如果笔记内容有错,请指出来. 对数据类型的操作 可变数据类型:列表,集合,字典 列表: ...
- Ajax做无刷新分页
1.主页面代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...
- Effective C++ 条款10
令operator=返回一个reference to *this 将operator=返回一个reference是为了什么呢?答案很简单,就是为了实现连锁形式. 什么是连锁形式,如int x,y,z: ...
- Linux U盘 启动盘
/****************************************************************************** * Linux U盘 启动盘 * 说明: ...
- loj#6566. 月之都的密码
搜交互题搜到的... 竟然还有这么水的交互题,赶紧过了再说 交互库里有一个 $[1,n]$ 到 $[1,n]$ 的双射 你可以调用 $encode(k,a[])$ 询问左边的一个大小为 $k$ 的集合 ...