티스토리 뷰
https://programmers.co.kr/learn/courses/30/lessons/42576
코딩테스트 연습 - 완주하지 못한 선수
수많은 마라톤 선수들이 마라톤에 참여하였습니다. 단 한 명의 선수를 제외하고는 모든 선수가 마라톤을 완주하였습니다. 마라톤에 참여한 선수들의 이름이 담긴 배열 participant와 완주한 선수��
programmers.co.kr
import java.util.*;
class Solution {
public String solution(String[] participant, String[] completion) {
Arrays.sort(participant);
Arrays.sort(completion);
int i;
for(i=0; i<completion.length; i++) {
if(!participant[i].equals(completion[i])) {
return participant[i];
}
}
return participant[i];
}
}
'ALGORITHM' 카테고리의 다른 글
[JAVA] [프로그래머스] Level 1 - 연습문제 - 같은 숫자는 싫어 (0) | 2020.08.31 |
---|---|
[JAVA] [프로그래머스] Level 1 - 연습문제 - 가운데 글자 가져오기 (0) | 2020.08.30 |
[JAVA] [프로그래머스] Level 1 - 정렬 - K번째 수 (0) | 2020.08.30 |
[JAVA] [프로그래머스] Level 1 - 그리디 - 체육복 (0) | 2020.08.29 |
[JAVA] [프로그래머스] Level 1 - 완전탐색 - 모의고사 (0) | 2020.08.29 |