I just need help with part 1.Part 2 is optional, you may want to do part2 to ver
ID: 3552689 • Letter: I
Question
I just need help with part 1.Part 2 is optional, you may want to do part2 to verify your function for part 1 works.
Explanation / Answer
vector<int> merge_vector(vector<int> v0, vector<int> v1)
{
int i,j,k;
vector<int> v2;
for(i=0,j=0,k=0; i<v0.size() && j<v1.size(); k++)
{
if(k%2==0)
{
v2.push_back(v0[i]);
i++;
}
else
{
v2.push_back(v1[j]);
j++;
}
}
while(i<v0.size() )
{
v2.push_back(v0[i]);
i++;
}
while(j<v1.size() )
{
v2.push_back(v1[j]);
j++;
}
return v2;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.