Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def largeGroupPositions(self, S):
- """
- :type S: str
- :rtype: List[List[int]]
- """
- last = None
- result = []
- start = 0
- end = 0
- for i in range(len(S)):
- if S[i] == last:
- end = i
- else:
- if end - start >= 2:
- result.append([start, end])
- last = S[i]
- start = i
- end = i
- if end - start >= 2:
- result.append([start, end])
- return result
Add Comment
Please, Sign In to add comment