1.题目要求:
2.题目代码:
csharp
class Solution {
public:
vector<int> shuffle(vector<int>& nums, int n) {
vector<int> x_array(nums.begin(),nums.begin() + n);
vector<int> y_array(nums.begin() + n,nums.end());
int x_index = 0;
int y_index = 0;
for(int i = 0;i < nums.size();i++){
if(i % 2 == 0){
nums[i] = x_array[x_index];
x_index++;
}else{
nums[i] = y_array[y_index];
y_index++;
}
}
return nums;
}
};