-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path830.cpp
38 lines (35 loc) · 1.07 KB
/
830.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Solution {
public:
vector<vector<int>> largeGroupPositions(string S) {
int i = 0;
vector<vector<int>> result;
while(i < S.length()){
int j = i + 1;
while(j < S.length()){
if(S[j] == S[i]){
j++;
}else{
if(j - i >=3){
vector<int> oneResult;
oneResult.push_back(i);
oneResult.push_back(j-1);
result.push_back(oneResult);
}
i = j;
break;
}
}
if(j == S.length()){
if(j - i >=3){
vector<int> oneResult;
oneResult.push_back(i);
oneResult.push_back(j-1);
result.push_back(oneResult);
}
i = j;
break;
}
}
return result;
}
};