본문 바로가기

프로그래밍/Baekjoon

(파이썬) 백준 알고리즘 1316번 그룹 단어 체커

문제

풀이 (Python)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
cnt = 0;
= int(input())
for i in range(N):
    check= [0]*26
    flag = 1;
    word = input()
    n = len(word)
    
    for j in range(n):
        if check[ord(word[j])- 97]:
            if word[j] != word[j-1]:
                flag = 0;
                break
        check[ord(word[j])-97= 1
    check = [0]*26
    
    if flag:
        cnt +=1
print(cnt)
cs

문제 출처