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 ...
随机推荐
- Spring初学之通过工厂方法配置Bean
工厂方法配置bean分为两种,一种是实例工厂方法,另一种是静态工厂方法. 先来看看实体bean: Car.java: package spring.beans.factory; public clas ...
- chromedriver驱动的浏览器和真实浏览器之间的差异
一. 打印百度首页底部的声明 如图,想打印@2018 Baidu...后面的一长串文字,可以通过class name定位的形式 可以看出,只有一个class name是"copyright- ...
- hdu 5244 inverse(分治¥)
inverse Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- ES6环境配置
1.电脑有node环境,运行npm init 2.cnpm i -D babel-core babel-preset-es2015 babel-preset-latest 3.创建.babelrc文件 ...
- LeetCode OJ:Count Complete Tree Nodes(完全二叉树的节点数目)
Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from W ...
- LeetCode OJ:Triangle(三角形)
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...
- GUID在.net里的使用
GUID(全局统一标识符)是指在一台机器上生成的数字,它保证对在同一时空中的所有机器都是唯一的.通常平台会提供生成GUID的API.生成算法很有意思,用到了以太网卡地址.纳秒级时间.芯片ID码和许多可 ...
- 使用Python和OpenCV通过网址URL获取图片
在OpenCV中通过图片的URL地址获取图片: # -*- coding: utf-8 -*- import numpy as np import urllib import cv2 # URL到图片 ...
- tf.random_normal()函数
tf.random_normal()函数用于从服从指定正太分布的数值中取出指定个数的值. tf.random_normal(shape, mean=0.0, stddev=1.0, dtype=tf. ...
- RedHat5.8 编译内核驱动 合成initrd.img
/******************************************************************* * RedHat5.8 编译内核驱动 合成initrd.img ...