-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path전화번호목록.java
37 lines (32 loc) · 873 Bytes
/
전화번호목록.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
// 본인 풀이
class Solution {
public boolean solution(String[] phone_book) {
boolean result = true;
List<String> names = Arrays.asList(phone_book);
Stream<String> a = names.stream().filter(x -> x.contains(phone_book[0]) && !x.equals(phone_book[0]));
if(a.count() != 0) {
result = false;
}
return result;
}
}
// 타인 풀이
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
class Solution {
public boolean solution(String[] phone_book) {
Arrays.sort(phone_book);
for(int i = 0 ; i < phone_book.length -1 ; i++) {
if(phone_book[i+1].startsWith(phone_book[i])) {
return false;
}
}
return true;
}
}