leetcode830
public class Solution
{
public IList<IList<int>> LargeGroupPositions(string S)
{
//"babaaaabbb"
var list = new List<IList<int>>();
int len = S.Length;
if (len > )
{
var last = S[];
var begin = ;
var end = S.Length - ; for (int i = ; i < len; i++)
{
var cur = S[i];
if (last != cur)
{
end = i - ;
var dif = end - begin + ;
if (dif >= )
{
var poslist = new List<int>();
poslist.Add(begin);
poslist.Add(end);
list.Add(poslist);
}
last = S[i];
begin = i;
}
end = i;
} if (end - begin >= )
{
var list3 = new List<int>();
list3.Add(begin);
list3.Add(end);
list.Add(list3);
}
} return list;
}
}
leetcode830的更多相关文章
- [Swift]LeetCode830. 较大分组的位置 | Positions of Large Groups
In a string S of lowercase letters, these letters form consecutive groups of the same character. For ...
- Leetcode830.Positions of Large Groups较大分组的位置
在一个由小写字母构成的字符串 S 中,包含由一些连续的相同字符所构成的分组. 例如,在字符串 S = "abbxxxxzyy" 中,就含有 "a", " ...
- 使用Python一步一步地来进行数据分析总结
原文链接:Step by step approach to perform data analysis using Python译文链接:使用Python一步一步地来进行数据分析--By Michae ...
随机推荐
- 为Linux服务器的SSH登录启用Google两步验证
对于Linux服务器而言使用密钥登录要比使用密码登录安全的多,毕竟当前网上存在多个脚本到处进行爆破. 这类脚本都是通过扫描IP端的开放端口并使用常见的密码进行登录尝试,因此修改端口号也是非常有必要的. ...
- 解决使用 aapt 中遇到的问题
|---- yum install glibc.i686 libstdc++.i686 zlib.i686 -y; .csharpcode, .csharpcode pre { font-size: ...
- Python timedelta
datetime.timedelta对象代表两个时间之间的的时间差,两个date或datetime对象相减时可以返回一个timedelta对象. 构造函数: class datetime.time ...
- 使用Linq动态排序
Linq排序很方便,如果能动态创建Expression再排序就更方便了. 正序还是倒序排列 var order = typeof(Enumerable).GetMember(direction == ...
- 我在ubuntu14.04安装使用的软件
搜狗拼音sougoupinyin:sudo add-apt-repository ppa:fcitx-team/nightly && sudo apt-get updatesudo a ...
- POJ1733 Parity game 【带权并查集】*
POJ1733 Parity game Description Now and then you play the following game with your friend. Your frie ...
- pat甲级 1154 Vertex Coloring (25 分)
A proper vertex coloring is a labeling of the graph's vertices with colors such that no two vertices ...
- LOJ #3049. 「十二省联考 2019」字符串问题
LOJ #3049. 「十二省联考 2019」字符串问题 https://loj.ac/problem/3049 题意:给你\(na\)个\(A\)类串,\(nb\)个\(B\)类串,\(m\)组支配 ...
- Django基于Form之登录和注册
1.创建Forms文件,内容略多,大家将就着看,不懂请留言 #!/usr/bin/env python # -*- coding: utf8 -*- #__Author: "Skiler H ...
- elipse中开发servlet,直接run as 时出现404错误的解决方法
在elipse中开发servlet时,无论在IDE中运行,还是在浏览器中访问servlet时,一直报404错误, 后发现在build目录中没有生成相应的类文件,后反复采用project中的clean. ...