[IT]/백준
[백준] 1316번 그룹 단어 체커
working_hard
2019. 5. 25. 15:17
728x90
package for문연습;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int num = Integer.parseInt(br.readLine());
int count = num;
for (int i = 0; i < num; i++) {
String s = br.readLine();
String [] sp = s.split("");
boolean [] arr = new boolean [26];
for (int j = 0; j < sp.length; j++) {
int idx = sp[j].charAt(0)-'a';
if(!arr[idx]) {
arr[idx] = true;
}else {
if(j==0) {
continue;
}else {
if(idx==sp[j-1].charAt(0)-'a') {
continue;
}else {
count--;
break;
}
}
}
}
}
System.out.println(count);
}
}
포인트 : j==0 일때의 예외처리를 할 수 있는가?
그 전 단어가 일치하는 것을 구현할 수 있는가?
boolean 단어로 체킹할 수 있는가?
단순한 구현 문제였던 것 같다.