공부기록/프로그래머스

[프로그래머스] 최댓값과 최솟값

메델 2023. 8. 31. 08:03
import java.util.*;

class Solution {
    public String solution(String s) {
        String answer = "";
        String[] arr = s.split(" ");
        int[] arrNumber = new int [arr.length];

        for(int i=0; i<arr.length; i++){
            arrNumber[i]= Integer.parseInt(arr[i]);
        }
        
        Arrays.sort(arrNumber);     
        int length = arrNumber.length;

        answer = arrNumber[0] + " "+ arrNumber[length-1];

        return answer;
    }
}