830. Positions of Large Groups
Posted zhuangbijingdeboke
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了830. Positions of Large Groups相关的知识,希望对你有一定的参考价值。
1 class Solution 2 { 3 public: 4 vector<vector<int>> largeGroupPositions(string S) 5 { 6 S.push_back(‘ ‘); 7 int pre=0; 8 int len=S.length(); 9 vector<vector<int>> res; 10 for(int i=0;i<len;i++) 11 { 12 if(S[i]!=S[pre]) 13 { 14 if(i-pre>2) 15 res.push_back({pre,i-1}); 16 pre=i; 17 } 18 } 19 return res; 20 } 21 };
这题比较简单了,没啥说的,问题不大
以上是关于830. Positions of Large Groups的主要内容,如果未能解决你的问题,请参考以下文章
830. Positions of Large Groups@python
LeetCode 830. Positions of Large Groups
830. Positions of Large Groups - LeetCode
830. Positions of Large Groups