Skip to content

Commit ea34051

Browse files
authored
feat:PG_42576 (#8)
1 parent ee2bd58 commit ea34051

File tree

4 files changed

+69
-5
lines changed

4 files changed

+69
-5
lines changed

.github/pull_request_template.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 📌 문제 링크
2+
(문제 링크 또는 문제 캡처본을 첨부해주세요.)
3+
4+
5+
---
6+
7+
## 📝 문제 개요
8+
-
9+
10+
---
11+
12+
## 🧩 풀이 과정 요약
13+
-
14+
15+
---
16+
17+
## 😁 결과
18+
(문제 해결 결과를 첨부해주세요.)

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/week01/Yoepee/BOJ_1000.java

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/week01/Yoepee/PG_42576.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package week01.Yoepee;
2+
3+
import java.util.*;
4+
5+
public class PG_42576 {
6+
public static String solution(String[] participant, String[] completion) {
7+
String answer = "";
8+
Arrays.sort(participant);
9+
Arrays.sort(completion);
10+
for(int i =0; i<participant.length; i++){
11+
if (i == participant.length-1) return participant[i];
12+
if (participant[i].equals(completion[i]) == false) {
13+
return participant[i];
14+
}
15+
}
16+
return answer;
17+
}
18+
19+
public static String solution2(String[] participant, String[] completion) {
20+
String answer = "";
21+
Map<String, Integer> map = new HashMap<>();
22+
for(int i =0; i<participant.length;i++){
23+
map.merge(participant[i], 1, (v1, v2) -> Math.max(v1,v2)+1);
24+
}
25+
for(int i =0; i<completion.length;i++){
26+
map.merge(completion[i], 0, (v1, v2) -> v1-1);
27+
}
28+
for(int i =0; i<participant.length;i++){
29+
if(map.get(participant[i]) == 1){
30+
answer =participant[i];
31+
break;
32+
}
33+
}
34+
35+
return answer;
36+
}
37+
38+
public static void main(String[] args) {
39+
// 정상 결과: "leo"
40+
System.out.println(solution(new String[]{"leo", "kiki", "eden"}, new String[]{"eden", "kiki"}));
41+
// 정상 결과: "vinko"
42+
System.out.println(solution(new String[]{"marina", "josipa", "nikola", "vinko", "filipa"}, new String[]{"josipa", "filipa", "marina", "nikola"}));
43+
// 정상 결과: "mislav"
44+
System.out.println(solution(new String[]{"mislav", "stanko", "mislav", "ana"}, new String[]{"stanko", "ana", "mislav"}));
45+
// 정상 결과: "b"
46+
System.out.println(solution(new String[]{"a", "b", "a", "c", "d"}, new String[]{"a", "a", "c", "d"}));
47+
// 정상 결과: "b"
48+
System.out.println(solution(new String[]{"a", "a", "b", "a", "c", "d"}, new String[]{"a", "a", "a", "c", "d"}));
49+
}
50+
}

0 commit comments

Comments
 (0)