题目地址:https://leetcode-cn.com/problems/merge-two-sorted-lists/
解题思路:简单链表操作
class Solution { public: ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) { ListNode *Head=new ListNode(); ListNode *p,*q,*h; p=l1; q=l2; h=Head; while(p&&q){ if(p->val>=q->val){ h->next=q; h=h->next; q=q->next; } else{ h->next=p; h=h->next; p=p->next; } } if(p) h->next=p; else h->next=q; return Head->next; } };