Problem Solving/Programmers

[Level 2] n^2 배열 자르기

kmkunk 2022. 4. 7. 18:44
class Solution {
    public int[] solution(int n, long left, long right) {
        int len = (int)(right-left+1);
        int[] answer = new int[len];
        
        for(int i=0; i<answer.length; i++) {
            int x = (int)(left/n);
            int y = (int)(left%n);
            answer[i] = Math.max(x, y)+1;
            left++;
        }
        
        return answer;
    }
}