Hope the solution helps. I am using C++ as there is no language preference
#include <iostream>
#include <list>
#include <string>
using namespace std;
int main() {
//In the program we are using list. It is a data structure which helps us to merge two list easily
list<string> s1;
list<string> s2;
string a = "aasd";
string b = "bdds";
string c = "csd";
string d = "dsd";
string e = "efds";
s1.push_back(a);
s1.push_back(d);
s1.push_back(e);
s2.push_back(b);
s2.push_back(c);
s2.merge(s1);
s2.sort(); //Sort the list according so that the items get ordered
for (auto i : s2) {
cout << i << " ";
}
cout << "\n";
}
Get Answers For Free
Most questions answered within 1 hours.