Skip to content

Commit e806fbd

Browse files
committed
2019-05-29
1 parent b2f46d0 commit e806fbd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution(object):
2+
def largeGroupPositions(self, S):
3+
"""
4+
:type S: str
5+
:rtype: List[List[int]]
6+
"""
7+
start, end = 0, 0
8+
res = []
9+
i = 0
10+
while i < len(S) - 1:
11+
if S[i] == S[i + 1]:
12+
start = i
13+
end = i
14+
while(end < len(S) - 1 and S[end] == S[end + 1]):
15+
end += 1
16+
if end - start + 1 >= 3:
17+
res.append([start, end])
18+
i = end + 1
19+
start = end + 1
20+
continue
21+
i += 1
22+
return res

0 commit comments

Comments
 (0)