프로그래밍/백준

1316 그룹 단어 체커

게으른구름 2017. 10. 20. 11:10
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