practivceAlgorithm/백준

[백준][Python] 1316 그룹단어체커

findTheValue 2021. 8. 6. 01:21

떨어진 단어가 있나 없나 체크하는 문제.

단어 바뀌면 체크해주고 나중에 똑같은거  또나오면 멈춰주면 된다. 약간 구현스러운 문제

 

import sys
input = sys.stdin.readline
N = int(input())
cnt=0
for _ in range(N):
    chr_set = {i:0 for i in range(97,123)}
    word = input().rstrip()
    for i in range(len(word)):
        if chr_set[ord(word[i])]==1:
            break
        if i<len(word)-1 and word[i] != word[i+1]:
            chr_set[ord(word[i])]=1
    else:
        cnt+=1
print(cnt)

'practivceAlgorithm > 백준' 카테고리의 다른 글

[백준][Python] 14891 톱니바퀴  (0) 2021.08.07
[백준][Python] 1074 Z  (0) 2021.08.06
[백준][Pyhton] 9489 사촌  (0) 2021.08.06
[백준][Python] 3190 뱀  (0) 2021.08.06
[백준][Python] 14503 로봇청소기  (0) 2021.08.05