Commit 778ccbab authored by yaozc's avatar yaozc
Browse files


#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;
int main()
return 0;
//21 merge two sorted lists
//recrusion 写法,可以写成while loop形式,也可以最简单的创造新list,暴力解法
ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {
if (!(l1)) return l2;
if (!(l2)) return l1;
if(l1->val < l2->val){
l1->next = mergeTwoLists(l1->next, l2);
return l1;
l2->next = mergeTwoLists(l2->next, l1);
return l2;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment