import java.util.*;
class Solution {
public boolean solution(String[] phone_book) {
Map<String, String> hm = new HashMap<String, String>();
for(int i=0; i<phone_book.length-1; i++){
for(int j=i+1; j<phone_book.length; j++){
if(phone_book[i].startsWith(phone_book[j])) return false;
if(phone_book[j].startsWith(phone_book[i])) return false;
}
}
return true;
}
}
'코딩테스트' 카테고리의 다른 글
[프로그래머스]완주하지 못한 마라톤선수 (0) | 2021.02.04 |
---|---|
[Java]해커랭크 - Two Strings (0) | 2020.02.26 |
[Java]해커랭크 - Hash Tables: Ransom Note (0) | 2020.02.26 |
[Java]해커랭크 - Minimum Absolute Difference in an Array (0) | 2020.02.26 |
[Java]해커랭크 - Repeated String (0) | 2020.02.26 |