View

๋ฐ˜์‘ํ˜•

https://school.programmers.co.kr/learn/courses/30/lessons/42576

 

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.

programmers.co.kr

 

 

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๋ฅผ ์“ฐ๋„๋กํ•˜์ž...

์ €๊ฑฐ ์ฐพ๋Š๋ผ ๊ณ ์ƒ ๊ฝค๋‚˜ํ–ˆ๋„ค;;;;

https://ojava.tistory.com/15

 

equals์™€ ==์˜ ์ฐจ์ด์ 

equals์™€ ==์˜ ์ฐจ์ด์  equals ์™€ == ์€ ์–ด๋–ค ์ฐจ์ด์ ์ด ์žˆ์„๊นŒ์š”. ๊ธฐ๋ณธ์ ์œผ๋กœ ์ด ๋‘˜์€ ๋ชจ๋‘ ์–‘ ์ชฝ์— ์žˆ๋Š” ๋‚ด์šฉ์„ ๋น„๊ตํ•œ ๊ฐ’์„ boolean type์œผ๋กœ ๋ฐ˜ํ™˜ํ•œ๋‹ค๋Š” ๊ณตํ†ต์ ์„ ๊ฐ€์ง‘๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ฐจ์ด์ ์ด ๋ถ„๋ช… ์กด์žฌ

ojava.tistory.com

 

๋ฐ˜์‘ํ˜•
Share Link
reply
๋ฐ˜์‘ํ˜•
ยซ   2025/01   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31