가장 작은 수 제거하기.....
쉬워보였는데 어려웠다!
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class MinNum {
public int[] solution(int[] arr) {
int[] resultArray = new int[arr.length -1];
if (arr.length == 1) {
int[] one = {-1};
return one;
} else if (arr.length > 1) {
Arrays.sort(arr);
List<Integer> result = IntStream.of(arr).boxed().collect(Collectors.toList());
result.remove(0);
result.stream().mapToInt(Integer::intValue).toArray();
for (int i = 1; i < resultArray.length; i++) {
resultArray[i] = result.get(i);
}
}return resultArray;
}
public static void main(String[] args) {
MinNum solution = new MinNum();
int[] arr = {1,5,7,6,8};
System.out.println(solution.solution(arr));
}
}
정리는 다음에ㅠㅠㅠㅠㅠ머리아파