After completing I have seen better solutions, but anyway here it is....

```
class Solution {
public:
ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) {
ListNode* res = new ListNode(-1); // dummy
ListNode* r = res;
while (l1 || l2) {
while (l1 && (!l2 || l1->val <= l2->val)) {
r->next = new ListNode(l1->val);
r = r->next;
l1 = l1->next;
}
while (l2 && (!l1 || l2->val <= l1->val)) {
r->next = new ListNode(l2->val);
r = r->next;
l2 = l2->next;
}
}
return res->next;
}
};
```