-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
28 lines (21 loc) · 757 Bytes
/
Solution.java
File metadata and controls
28 lines (21 loc) · 757 Bytes
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
public class Solution {
public static void main(String[] args) {
String[] phone_book = {"119", "97674223", "1195524421"};
boolean answer = solution(phone_book);
System.out.println(answer);
}
public static boolean solution(String[] phone_book){
for(int i = 0 ; i < phone_book.length; i++){
String cur = phone_book[i];
for(int j=0; j<phone_book.length; j++){
if( i != j && ( cur.length() <= phone_book[j].length() ) ) {
String comp = phone_book[j].substring(0, cur.length());
if(cur.equals(comp)){
return false;
}
}
}
}
return true;
}
}