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
原文:https://www.cnblogs.com/zhuangbijingdeboke/p/9190654.html