from collections import deque
T = int(input())
def sol(T):
answer = 0
for _ in range(T):
p = deque(input()) #['h', 'a', 'p', 'p', 'y']
pp = len(p)
already = deque()
already_element = None
while p :
element = p.popleft()
if already_element == element and element not in already:
already.append(element)
already_element = element
elif already_element == element and element in already: #[h,a,p] p==p, p in [h,a,p]
already.append(element)
already_element = element
elif already_element != element and element not in already: #[a,b] b!=c, c not in [a,b]
already.append(element)
already_element = element
elif already_element != element and element in already: #[a,b,c] c!=a, a in [a,b,c]
break
if len(already) == pp:
answer += 1
return answer
print(sol(T))
풀이
deque로 풀이 가능하고, while문 속 if문에 따라 그룹 단어의 수를 더하도록 코드를 짰다.