문제 설명
해결과정
Solution.java
import java.util.*;
class Solution {
public String solution(String[] participant, String[] completion) {
String answer = "";
Arrays.sort(participant);
Arrays.sort(completion);
int length = participant.length-1;
int start = 0;
int end = completion.length-1;
if(participant.length != 1) {
for(int i = 0; i < participant.length/2+1; i++) {
if(!completion[start].equals(participant[i])) {
answer = participant[i];
break;
} else if(!completion[end-start].equals(participant[length-i])) {
answer = participant[length-i];
break;
}
start++;
}
} else {
answer = participant[0];
}
return answer;
}
}
Java
복사