Skip to content

Commit 1bd550f

Browse files
committed
[level 2] Title: 전화번호 목록, Time: 520.93 ms, Memory: 163 MB -BaekjoonHub
1 parent 339fa9a commit 1bd550f

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

프로그래머스/2/42577. 전화번호 목록/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 97.1 MB, 시간: 320.08 ms
7+
메모리: 163 MB, 시간: 520.93 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2025년 07월 14일 11:27:40
19+
2025년 09월 01일 14:53:05
2020

2121
### 문제 설명
2222

프로그래머스/2/42577. 전화번호 목록/전화번호 목록.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
import java.util.*;
22
class Solution {
3-
public boolean solution(String[] s) {
4-
Arrays.sort(s); // 사전순 정렬
5-
for(int i = 0; i<s.length-1; i++){
6-
if(s[i+1].startsWith(s[i])) return false;
3+
public boolean solution(String[] phone_book) {
4+
String[] answer = new String[phone_book.length];
5+
int i =0;
6+
for(String number : phone_book){
7+
answer[i++] = number.replaceAll(" ","");
8+
}
9+
Arrays.sort(answer);
10+
11+
for(int idx = 1;idx < answer.length;idx++) {
12+
String period = answer[idx-1];
13+
String current = answer[idx];
14+
15+
if(current.startsWith(period)){
16+
return false;
17+
}
718
}
819
return true;
920
}

0 commit comments

Comments
 (0)