View
[ํ๋ก๊ทธ๋๋จธ์ค] ์์ฃผํ์ง ๋ชปํ ์ ์(Java)
์ฑ ์ฝ๋ ๊ฐ์ 2022. 10. 1. 23:52๋ฐ์ํ
https://school.programmers.co.kr/learn/courses/30/lessons/42576
import java.util.*;
class Solution {
public String solution(String[] participant, String[] completion) {
String answer ="";
Arrays.sort(participant);
Arrays.sort(completion);
// ์์ฃผ์ ํค์์ ์ฐธ๊ฐ์ ํค์ ๋ฒจ๋ฅ๊ฐ ์ผ์นํ์ง ์๋ ์ฌ๋ -> ์๋ ์ฌ๋
for (int i=0; i<completion.length; i++){
if(!participant[i].equals(completion[i])) {
answer=participant[i];
return answer;
}
}
answer=participant[participant.length-1];
return answer;
}
}
๋ฌธ์์ด์ ๋น๊ตํ ๋๋ ==๋ณด๋จ equals๋ฅผ ์ฐ๋๋กํ์...
์ ๊ฑฐ ์ฐพ๋๋ผ ๊ณ ์ ๊ฝค๋ํ๋ค;;;;
๋ฐ์ํ
'์๊ณ ๋ฆฌ์ฆ > ์ฝ๋ฉํ ์คํธ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค_์คํจ] (0) | 2022.10.02 |
---|---|
[SWEA]1249: ๋ณด๊ธ๋ก D4(Java) (0) | 2022.10.02 |
[๋ฐฑ์ค] 2879: ์ํ์์ (Java) (0) | 2022.10.01 |
[์ฝ๋ฉํ ์คํธ] ์ฝํ ๋๋น ๋ฌธ์ ์ถ์ฒ (0) | 2022.10.01 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฌธ์์ด ๋ด ๋ง์๋๋ก ์๋ฅด๊ธฐ(Java) (0) | 2022.10.01 |
reply