File tree 1 file changed +26
-0
lines changed
docs/data-structure/array
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -2935,6 +2935,32 @@ func getMin(a int, b int) int {
2935
2935
}
2936
2936
```
2937
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
+ count = 1
2958
+ else :
2959
+ count += 1
2960
+
2961
+ return ans
2962
+ ```
2963
+
2938
2964
## 914. 卡牌分组
2939
2965
2940
2966
[ 原题链接] ( https://leetcode-cn.com/problems/x-of-a-kind-in-a-deck-of-cards/ )
You can’t perform that action at this time.
0 commit comments