Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[2주차] #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
EunjiShin merged 2 commits into TecheerB:master from EunjiShin:master
Nov 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions EunjiShin/PS/programmers/해시/완주하지 못한 선수.java
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import java.util.*;

class Solution {
public String solution(String[] participant, String[] completion) {
String answer = "";
Map<String, Integer> map = new HashMap<>();

for(String str : participant){
map.put(str, map.getOrDefault(str, 0)+1);
}

for(String str : completion){
map.put(str, map.get(str)-1);
}

for(String key : map.keySet()){
if(map.get(key) == 1){
answer = key;
}
}

return answer;
}
}
33 changes: 33 additions & 0 deletions EunjiShin/PS/programmers/해시/전화번호 목록.java
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.util.*;

class Solution {
public boolean solution(String[] phone_book) {
boolean answer = true;
Map<String, String> map = new HashMap<>();

Arrays.sort(phone_book);
for(String phone_number : phone_book){
map.put(phone_number, "1");
}

for(String phone_number : phone_book){
for(int i=0; i<phone_number.length(); i++){
String str = phone_number.substring(0, i);
if(map.containsKey(str)){
return false;
}
}
}

// Hash없이 푼다면 startsWith
// Arrays.sort(phone_book);
// for (int i=0; i<phone_book.length-1; i++) {
// if (phone_book[i+1].startsWith(phone_book[i])) {
// answer = false;
// break;
// }
// }

return answer;
}
}

AltStyle によって変換されたページ (->オリジナル) /