void construct(int t, Node* &head, Node* &tail) {
Node* node = newNode(t);
if (head == NULL) {
head = node;
tail = node;
} else {
tail->next = node;
tail = node;
}
}
static bool comp(int a, int b) {
return a > b;
}
void store(Node* root,vector<int>&v)
{
Node *node=root;
while(node)
{
v.push_back(node->data);
node=node->next;
}
}
struct Node * mergeResult(Node *node1,Node *node2)
{
vector<int> v;
store(node1,v);
store(node2,v);
sort(v.begin(),v.end(),comp);
Node* head=NULL;
Node* tail=NULL;
for(auto it:v)
{
construct(it,head,tail);
}
return head;
}