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

2020. 3. 28. 14:55프로그래머스/LEVEL 2

import java.util.*;

class Solution {
  public String solution(String s) {
      String answer = "";
      
      String[] temp = s.split(" ");
      int[] numlist = new int[temp.length];
      
      for(int i=0; i<numlist.length; i++){
          numlist[i] = Integer.parseInt(temp[i]);
      }
      
      Arrays.sort(numlist);
      
      answer = Integer.toString(numlist[0]) + " " + Integer.toString(numlist[numlist.length-1]);
      return answer;
  }
}