MapleStory Finger Point

๐Ÿƒ‍โ™€๏ธprogrammers/Java

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค - java ๋’ค์—์„œ 5๋“ฑ๊นŒ์ง€

HYEJU01 2024. 5. 9. 14:18

 ๐Ÿ’ก ๊ฐ€์žฅ ์ž‘์€ 5๊ฐœ์˜ ์ˆ˜๋ฅผ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ฆฌํ•ด์•ผํ•œ๋‹ค.

 

์ด ๊ฒฝ์šฐ ๋จผ์ € ๋ฐฐ์—ด์˜ ๊ฐ’์„ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ฆฌํ•œ ๋’ค,

์•ž์—์„œ๋ถ€ํ„ฐ 5๊ฐœ๋ฅผ ์ฝ์–ด์˜ค๋ฉด ๋œ๋‹ค.

 

 

 ๐Ÿ’ฌArrays.sort() :: ์ •์ˆ˜ ๋ฐฐ์—ด์„ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•œ๋‹ค

 

import java.util.Arrays;

class Solution {
    public int[] solution(int[] num_list) {
        int[] answer = new int[5];
        
        Arrays.sort(num_list); 
        
        for (int i =0 ; i<5; i++){
            answer[i] = num_list[i];
        }

        return answer;
    }
}