File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
### 성능 요약
6
6
7
- 메모리: 28776 KB, 시간: 68 ms
7
+ 메모리: 13096 KB, 시간: 120 ms
8
8
9
9
### 분류
10
10
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments