Skip to content

Commit 783c246

Browse files
authored
Merge pull request #82 from gauravks99/master
Create 1470. Do Shuffle the Array.cpp
2 parents 2d55283 + b88aa74 commit 783c246

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class Solution {
2+
public:
3+
vector<int> shuffle(vector<int>& nums, int n) {
4+
5+
vector<int> new1;
6+
for(int i=0;i<=n-1;i++)
7+
{
8+
new1.push_back(nums[i]);
9+
10+
}
11+
vector<int> new2;
12+
for(int i=n;i<=2*n-1;i++)
13+
{
14+
new2.push_back(nums[i]);
15+
16+
}
17+
vector<int> new3;
18+
for(int i=0;i<n;i++)
19+
{
20+
new3.push_back(new1[i]);
21+
new3.push_back(new2[i]);
22+
23+
}
24+
return new3;
25+
}
26+
};

0 commit comments

Comments
 (0)