Leetcode 857 Solution
This article provides solution to leetcode question 857 (positions-of-large-groups)
Access this page by simply typing in "lcs 857" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/positions-of-large-groups
Solution
class Solution {
public:
vector<vector<int>> largeGroupPositions(string S) {
vector<vector<int>> ans;
int l = 0;
for (int r = 0; r <= S.size(); r++)
{
if (S[l] != S[r])
{
if (r - l >= 3)
ans.push_back({l, r - 1});
l = r;
}
}
return ans;
}
};