코딩테스트/프로그래머스
[해시] Level 1 완주하지 못한 선수 - JAVA
의정부핵꿀밤
2022. 2. 11. 13:44
728x90
https://yummy0102.tistory.com/186?category=966544
[해시] Level 1 완주하지 못한 선수
문제 설명 수많은 마라톤 선수들이 마라톤에 참여하였습니다. 단 한 명의 선수를 제외하고는 모든 선수가 마라톤을 완주하였습니다. 마라톤에 참여한 선수들의 이름이 담긴 배열 participant와 완
yummy0102.tistory.com
이 문제를 이번엔 자바 코드로 풀어봤다~
자바코드)
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];
}
}
알고리즘은 똑같!
import java.util.*; 로 선언하면 사용하기 편하더라~~
728x90