Skip to content

Commit d63e8e9

Browse files
committed
[PGS] 전화번호목록 / Level2 (Java 풀이) / 30분 / 실패
1 parent 4db6900 commit d63e8e9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import java.util.*;
2+
3+
class Solution {
4+
public boolean solution(String[] phone_book) {
5+
6+
Arrays.sort(phone_book); // 오름차순 정렬
7+
8+
for (int i = 0; i < phone_book.length - 1; i++ ) {
9+
// 만약 다음 값이 현재 값으로 시작한다면, false 반환
10+
if (phone_book[i+1].startsWith(phone_book[i])) {
11+
return false;
12+
}
13+
}
14+
return true;
15+
}
16+
}

0 commit comments

Comments
 (0)