프로그래머스 181891 순서 바꾸기

1 개요[ | ]

프로그래머스 181891 순서 바꾸기

2 C++[ | ]

#include <string>
#include <vector>

using namespace std;

vector<int> solution(vector<int> num_list, int n) {
    vector<int> answer(num_list.begin()+n, num_list.end());
    answer.insert(answer.end(), num_list.begin(), num_list.begin()+n);
    return answer;
}
#include <string>
#include <vector>

using namespace std;

vector<int> solution(vector<int> num_list, int n) {
    vector<int> answer = vector<int>(num_list.begin()+n, num_list.end());
    answer.insert(answer.end(), num_list.begin(), num_list.begin()+n);
    return answer;
}
#include <string>
#include <vector>

using namespace std;

vector<int> solution(vector<int> num_list, int n) {
    vector<int> answer;
    answer.reserve(num_list.size());
    answer.insert(answer.end(), num_list.begin()+n, num_list.end());
    answer.insert(answer.end(), num_list.begin(), num_list.begin()+n);
    return answer;
}
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> solution(vector<int> num_list, int n) {
    rotate(num_list.begin(), num_list.begin()+n,num_list.end());        
    return num_list;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}