blob: 8657dd60dfab0fd6a1015da9da7467dd6d8908d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include <vector>
using std::vector;
class Solution
{
public:
vector<int> shuffle(vector<int> &nums, int n)
{
vector<int> result;
result.resize(nums.size());
auto iter = result.begin();
auto iter1 = nums.cbegin();
auto iter2 = nums.cbegin() + n;
for (int i = 0; i < n; i++)
{
*iter++ = *iter1++;
*iter++ = *iter2++;
}
return std::move(result);
}
};
|