프로그래머스 - 최댓값과 최솟값

Jongleee·2022년 7월 21일
1

알고리즘

목록 보기
38/39
import java.util.ArrayList;
import java.util.Collections;

class Solution {
    public String solution(String s) {
        String[]str=s.split(" ");
        ArrayList<Integer> integerList = new ArrayList<>();
        String answer = "";
        for (int i = 0; i < str.length; i++) {
            integerList.add(Integer.valueOf(str[i]));
        }
        Collections.sort(integerList);
        answer=integerList.get(0)+" "+integerList.get(str.length-1);

        return answer;
    }
}

0개의 댓글