https://school.programmers.co.kr/learn/courses/30/lessons/87390

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

 

너무 쉽다했더니 함정이 있었습니다.

 

import java.io.*;
import java.util.*;
import java.util.Map.*;
class Solution {
    public int[] solution(int n, long left, long right) {

        long diff = right - left;
        int[] answer = new int[(int)diff  + 1];
        int answerindex =0;
        
        for(long a=left; a<=right;a++){
            answer[answerindex++] = (int)Math.max(a/n,a%n)+1;
        }
        
            
        
        return answer;
    }
}

+ Recent posts