Skip to content

Commit

Permalink
Merge pull request #57 from AlgoLeadMe/17-mong3125
Browse files Browse the repository at this point in the history
17-mong3125
  • Loading branch information
tgyuuAn authored Jun 27, 2024
2 parents bbde794 + 2cc73b2 commit 7a4da2f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions mong3125/ν•΄μ‹œ.P_μ „ν™”λ²ˆν˜Έλͺ©λ‘.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import java.util.HashSet;

class Solution {
public boolean solution(String[] phone_book) {

HashSet<String> set = new HashSet<>();

for (String phoneNum : phone_book) {
set.add(phoneNum);
}

for (String phoneNum : phone_book) {
for (int i = 0; i < phoneNum.length(); i++) {
if (set.contains(phoneNum.substring(0, i))) return false;
}
}

return true;
}
}

0 comments on commit 7a4da2f

Please sign in to comment.