입력값 :
"1 2 3 4" |
import java.util.stream.Stream;
import java.util.Arrays;
class Solution {
public String solution(String s) {
String answer = "";
int [] arr = Stream.of(s.split(" ")).mapToInt(Integer::parseInt).toArray();
Arrays.sort(arr);
answer = arr[0] + " " + arr[arr.length-1];
//최소값 + 최대값 출력
return answer;
}
}
Stream 개꿀!
댓글
댓글 쓰기