본문 바로가기

프로그래밍/백준

1316 그룹 단어 체커

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.*;
 
public class Main {
 
    static int count = 0;
 
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        String[] group_word = new String[N];
 
        for(int i=0; i<N; i++) {
            group_word[i] = sc.next();
            check_group_word(group_word[i]);
        }
 
        System.out.println(count);
    }
 
    static void check_group_word(String in) {
        int[] spelling = new int[26];
        boolean is_group_word = true;
 
        spelling[in.charAt(0)-'a']++;
 
        for(int i=1; i<in.length(); i++) {
            if(in.charAt(i-1== in.charAt(i) || spelling[in.charAt(i)-'a'== 0) {
                spelling[in.charAt(i)-'a']++;
            }
            else {
                is_group_word = false;
            }
        }
 
        if(is_group_word) {
            count++;
        }
    }
}
cs


'프로그래밍 > 백준' 카테고리의 다른 글

5622 다이얼  (0) 2018.02.08
2908 상수  (0) 2018.02.08
1157 단어 공부  (0) 2017.10.20
2675 문자열 반복  (0) 2017.10.15
10809 알파벳 찾기  (0) 2017.10.15