[알고리즘] (프로그래머스) 완주하지 못한 선수

이용찬·2022년 1월 5일
0

알고리즘

목록 보기
21/31
post-thumbnail

문제
(프로그래머스) 완주하지 못한 선수

Java 풀이

import java.util.*;

class Solution {
    public String solution(String[] participant, String[] completion) {
        String result = "";
        Arrays.sort(participant);
        Arrays.sort(completion);
        
        for(int i = 0; i < completion.length; i++) {
            if(!(participant[i].equals(completion[i]))) {
                result += participant[i];
				
                return result;
            }
        }
        
        result += participant[participant.length - 1];
        
        return result;
    }
}
profile
안녕하세요. 클래식을 즐기는 개발자, 이용찬입니다.

0개의 댓글