-Code
import java.util.stream.IntStream;
class Solution {
public int[] solution(int num, int total) {
int start = num % 2 == 0 ?
total / num - (num / 2) + 1 :
total / num - (num / 2);
int end = total / num + (num / 2);
return IntStream.rangeClosed(start, end).toArray();
}
}
'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
[프로그래머스/Java] 겹치는 선분의 길이 (1) | 2025.02.21 |
---|---|
[프로그래머스/Java] 안전지대 (0) | 2025.02.21 |
[프로그래머스/Java] 다항식 더하기 (0) | 2025.02.21 |
[프로그래머스/Java] 특이한 정렬 (0) | 2025.02.21 |
[프로그래머스/Java] 유한소수 판별하기 (0) | 2025.02.21 |