TIL_5주차(3) 코드카타: 알고리즘

원진·2025년 1월 15일

알고리즘
1. x만큼 간격이 있는 n개의 숫자

풀이:

#include <string>
#include <vector>

using namespace std;

vector<long long> solution(int x, int n) {
    vector<long long> answer;
    int start = x;
    for(int i = 0; i<n; ++i){
        answer.push_back(start);
        start += x;
    }
    return answer;
}

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

0개의 댓글