public int[] solution(int n, long left, long right) {
int length = (int) (right - left) + 1;
int[] answer = new int[length];
for (int i = 0; i < length; i++) {
long offset = (long) i + left;
int row = (int) (offset / n) + 1;
int col = (int) (offset % n) + 1;
answer[i] = Math.max(row, col);
}
return answer;
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/87390