728x90
반응형
Python
class Solution(object):
def largeGroupPositions(self, s):
"""
:type s: str
:rtype: List[List[int]]
"""
result = list()
before_str = ""
start_index = -1
for i, alphabet in enumerate(s+ " "):
if alphabet != before_str: # 현재 값과 이전 값이 다름
if i - start_index + 1 > 3:
result.append([start_index, i - 1])
before_str = alphabet
start_index = i
return result
728x90
반응형
'LeetCode > Easy' 카테고리의 다른 글
175. Combine Two Tables (0) | 2022.05.16 |
---|---|
155. Min Stack (0) | 2022.05.16 |
94. Binary Tree Inorder Traversal (0) | 2022.05.14 |
67. Add Binary (0) | 2022.05.14 |
104. Maximum Depth of Binary Tree (0) | 2022.05.07 |