Problem

Solution
Logic is pretty trivial in this case. Iterate over the two list simultaneously and compare the data values of the nodes in each list. Then take decision on which node should appear first in the merged list.
See below for the efficient implementation using recusrsive approach.

```#include<iostream>
using namespace std;

// list node structure
typedef struct list_node {
int data;
struct list_node *next;
}node;

// create new node
node *getNewNode(int data) {
node *new_node = new node;
new_node->data = data;
new_node->next = NULL;
return new_node;
}

// append a node to the list
else {
while (ptr->next != NULL)
ptr = ptr->next;
ptr->next = getNewNode(data);
}
}

// create a list
node *createList1() {
}

// create 2nd list
node *createList2() {
}

// traverse the list
while (ptr != NULL) {
cout<<ptr->data<<" ";
ptr = ptr->next;
}
}

// merge the two sorted list
node *mergeList(node *h1,node *h2) {
if (h2 == NULL) return h1;
if (h1 == NULL) return h2;
if(h1->data <= h2->data) {
h1->next = mergeList(h1->next,h2);
return h1;
}
else {
h2->next = mergeList(h1,h2->next);
return h2;
}
}

// main
main() {