문제 출처: https://www.acmicpc.net/problem/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
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
 
public class Main {
    
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(reader.readLine());
        int result = 0;
        
        for(int i=; i<N ; i++){
            String str = reader.readLine();
            ArrayList<Character> strList = new ArrayList<>();  
            
            for(int j=; j<str.length() ; j++){
                if(strList.contains(str.charAt(j)) && strList.get(strList.size()-1!= str.charAt(j)){
                    break;
                }
                else {
                    strList.add(str.charAt(j));
                    if(j==str.length()-1)
                        result++;
                }
            }
        }
    
        System.out.println(result);
    }
}
cs



'Algorithm' 카테고리의 다른 글

백준 5622번: 다이얼  (0) 2018.10.20
백준 2908번: 상수  (0) 2018.10.20
백준 1157번: 단어 공부  (0) 2018.10.20
백준 2675번: 문자열 반복  (0) 2018.10.20
백준 10809번: 알파벳 찾기  (0) 2018.10.20

+ Recent posts