Skip to content

Commit 58e6025

Browse files
committed
[Silver V] Title: 그룹 단어 체커, Time: 120 ms, Memory: 13096 KB -BaekjoonHub
1 parent 63136fc commit 58e6025

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

백준/Silver/1316. 그룹 단어 체커/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 28776 KB, 시간: 68 ms
7+
메모리: 13096 KB, 시간: 120 ms
88

99
### 분류
1010

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.util.ArrayList;
2+
import java.util.Scanner;
3+
4+
public class Main {
5+
public static void main(String[] args) {
6+
Scanner sc = new Scanner(System.in);
7+
int count = sc.nextInt();
8+
int sum = 0;
9+
for (int i = 0; i < count; i++) {
10+
if (check(sc.next())) {
11+
sum++;
12+
}
13+
}
14+
System.out.println(sum);
15+
}
16+
17+
public static boolean check(String str) {
18+
ArrayList<String> list = new ArrayList<>();
19+
for (int i = 0; i < str.length(); i++) {
20+
String word = str.substring(i, i + 1);
21+
if (!list.contains(word)) {
22+
list.add(word);
23+
} else if (str.charAt(i - 1) != str.charAt(i)) {
24+
// 리스트에 있는데 값이 다르면 false
25+
return false;
26+
}
27+
}
28+
return true;
29+
}
30+
}

0 commit comments

Comments
 (0)