Algorithm
백준 1316번: 그룹 단어 체커
qlyh8
2018. 10. 20. 02:50
문제 출처: 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=0 ; i<N ; i++){ String str = reader.readLine(); ArrayList<Character> strList = new ArrayList<>(); for(int j=0 ; 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 |