-Code
import java.util.*;
import java.util.stream.Collectors;
class Solution {
public int[] solution(int[] emergency) {
int[] sored_arr = Arrays.stream(emergency).sorted().toArray();
List<Integer> em_list = Arrays.stream(emergency).boxed().collect(Collectors.toList());
int priority = emergency.length;
int[] answer = new int[priority];
for (int num : sored_arr) {
answer[em_list.indexOf(num)] = priority--;
}
return answer;
}
}
'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
[프로그래머스/Java] 점의 위치 구하기 (0) | 2025.02.17 |
---|---|
[프로그래머스/Java] 순서쌍의 개수 (0) | 2025.02.17 |
[프로그래머스/Java] 외계행성의 나이 (0) | 2025.02.17 |
[프로그래머스/Java] 배열 자르기 (0) | 2025.02.17 |
[프로그래머스/Java] 특정 문자 제거하기 (0) | 2025.02.17 |