Tle exceeded in merging 2 ll

I applied the concept via recursion using 2 head of separate ll.but tle is exceeded.

@piyush.bansal8158625
The TLE is occuring due to your input function. Your input function takes approxiamately O(n^2) time to build a list. Your code never even gets to the sorting part due to this extremely time consuming buildList function. Use this function .
void buildList(node *&head,int n){
if(n == 0){
head = NULL ;
return ;
}
int x;
cin>>x; //first input;
head = new node(x);
node *current = head;
for(int i=1;i<n;i++){
cin>>x;
node *n = new node(x);
current->next = n;
current = n;
}
current->next = NULL;
}

This works in O(n) time and will solve the TLE problem.