LeetCode 830. 较大分组的位置
作者:互联网
简单题,主要考察索引计算和字符遍历,没什么难度;
vector<vector<int>> largeGroupPositions(string s) { vector<vector<int>> res; for (size_t i = 0; i < s.size();) { size_t index = i; size_t count = 1; for (size_t j = i + 1; j < s.size() && s[j] == s[i]; j++) count++; if (count >= 3) { vector<int>vec; vec.push_back(i); vec.push_back(i+count-1); res.push_back(vec); } i = i+count; } return res; }
标签:count,830,res,back,分组,vec,push,LeetCode,size 来源: https://www.cnblogs.com/songlinxuan/p/14233416.html