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 ...
随机推荐
- vue.js计算属性 vs methods
计算属性:Vue.js 模板内的表达式非常便利,但是缺点就是只能用于简单的运算,如果模板中有太多的逻辑运算会让模板不堪重负且难以维护.恰恰计算属性可以处理复杂的逻辑运算,也就是说对于任何复杂逻辑你都应 ...
- 转:Android命令Monkey压力测试,详解
停止Monkey命令: 1. ps命令 查找uiautomator的进程 打开cmd命令行窗口 输入: adb shell ps | grep monkey 返回来的第一个数字,即是monkey的进 ...
- C/C++输入数组
; printf("please enter the number:\n"); scanf("%d",&n); int *number=new int[ ...
- python 各种装饰器示例(python3)
参考网址: Python中的各种装饰器详解_python_脚本之家http://www.jb51.net/article/63892.htm 一.函数式装饰器: 1.装饰器无参数,被装饰对象无参数 d ...
- 关于const_cast转换
第一次看到const_cast转换,将const指针转换成普通的指针.很自然的想到:什么时候用const_cast?为什么要用它?这根const不是相互矛盾吗? (const_cast<ICef ...
- spring mvc中,如何在 Java 代码里,获取 国际化 内容
首先,在Spring的application.xml中定义 <bean id="messageSource" class="org.springframework. ...
- vue router按需加载
import Vue from 'vue' import Router from 'vue-router' Vue.use(Router); //按需加载,当渲染其他页面时才加载其组件,并缓存,减少首 ...
- SOLID
S.O.L.I.D是面向对象设计和编程(OOD&OOP)中几个重要编码原则(Programming Priciple)的首字母缩写. SRP The Single Responsibility ...
- CentOS学习笔记(一):中文语言包及输入法的安装使用
1.中文语言包安装 命令行执行: yum install fonts-chineseyum install fonts-ISO8859-2 2.切换成中文语言 菜单->System->Ad ...
- 面试题42:翻转单词顺序VS左旋转字符串
题目一:输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变.为简单起见,标点符号和普通字母一样处理. 例如输入字符串“I am a student.",则输出"stud ...