We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ab41c10 commit 42a8a36Copy full SHA for 42a8a36
docs/data-structure/array/README.md
@@ -2935,6 +2935,32 @@ func getMin(a int, b int) int {
2935
}
2936
```
2937
2938
+## 830. 较大分组的位置
2939
+
2940
+[原题链接](https://leetcode-cn.com/problems/positions-of-large-groups/)
2941
2942
+### 顺序遍历
2943
2944
+判断前后两个连续字母是否相同,若字母连续且当前字母连续出现次数已 >=3,那么加入结果集中。
2945
2946
+```python
2947
+class Solution:
2948
+ def largeGroupPositions(self, s: str) -> List[List[int]]:
2949
+ length = len(s)
2950
+ ans = []
2951
+ count = 1
2952
+ for i in range(length):
2953
+ if i == length - 1 or s[i] != s[i + 1]:
2954
+ # 出现不连续字母
2955
+ if count >= 3:
2956
+ ans.append([i - count + 1, i])
2957
2958
+ else:
2959
+ count += 1
2960
2961
+ return ans
2962
+```
2963
2964
## 914. 卡牌分组
2965
2966
[原题链接](https://leetcode-cn.com/problems/x-of-a-kind-in-a-deck-of-cards/)
0 commit comments