# Help me in solving HISC02 problem

### My code

``````#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
void FinalArray(int *arr1, int lenarr1, int *arr2, int lenarr2)
{
int *FinalArr = new int[lenarr1 + lenarr2];
int i = 0, j = 0, k = 0;
while (i < lenarr1)
{
FinalArr[k] = arr1[i];
i++;
k++;
}
while (j < lenarr2)
{
FinalArr[k] = arr2[j];
j++;
k++;
}
sort(FinalArr, FinalArr + lenarr1 + lenarr2);

for (int i = 0; i < (lenarr1 + lenarr2); i++)
{
cout << FinalArr[i] << " ";
}
cout << endl;
}
void takeElement(int *arr, int size)
{
for (int i = 0; i < size; i++)
{
cin >> arr[i];
}
}

int main()
{
int t;
cin >> t;
while (t--)
{
int lenarr1, lenarr2;
cin >> lenarr1 >> lenarr2;
int *arr1 = new int[lenarr1];
int *arr2 = new int[lenarr2];

takeElement(arr1, lenarr1);
takeElement(arr2, lenarr2);

FinalArray(arr1, lenarr1, arr2, lenarr2);
}
return 0;
}

``````

Problem Link: HISC02 Problem - CodeChef

@abhishek3536
your code is correct but u have to print “sorted list :” before printing the array.
include
include
include
include
include
include <bits/stdc++.h>
using namespace std;
void FinalArray(int *arr1, int lenarr1, int *arr2, int lenarr2)
{
int *FinalArr = new int[lenarr1 + lenarr2];
int i = 0, j = 0, k = 0;
while (i < lenarr1)
{
FinalArr[k] = arr1[i];
i++;
k++;
}
while (j < lenarr2)
{
FinalArr[k] = arr2[j];
j++;
k++;
}
sort(FinalArr, FinalArr + lenarr1 + lenarr2);
cout<<"sorted list : ";
for (int i = 0; i < (lenarr1 + lenarr2); i++)
{
cout << FinalArr[i] << " ";
}
cout << endl;
}
void takeElement(int *arr, int size)
{
for (int i = 0; i < size; i++)
{
cin >> arr[i];
}
}

int main()
{
int t;
cin >> t;
while (t–)
{
int lenarr1, lenarr2;
cin >> lenarr1 >> lenarr2;
int *arr1 = new int[lenarr1];
int *arr2 = new int[lenarr2];

``````    takeElement(arr1, lenarr1);
takeElement(arr2, lenarr2);

FinalArray(arr1, lenarr1, arr2, lenarr2);
}
return 0;
``````

}