본문 바로가기

코딩 테스트/알고리즘

x만큼 간격이 있는 n개의 숫자 - JAVA

반응형
class Solution {
    public long[] solution(int x, int n) {
        long[] answer = new long[n];
        int temp = 0;
        for (int i=0; i<n; i++){
            temp += x;
            answer[i] = temp; 
        }
        return answer;
    }
}
반응형