我是靠谱客的博主 踏实白羊,这篇文章主要介绍力扣------合并两个有序链表,现在分享给大家,希望可以做个参考。

在这里插入图片描述

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* mergeTwoLists(struct ListNode* list1, struct ListNode* list2){ if(list1==NULL){ return list2; } if(list2==NULL){ return list1; } if(list1->val<list2->val){ list1->next=mergeTwoLists(list1->next,list2); return list1; } else{ list2->next=mergeTwoLists(list1,list2->next); return list2; } }

最后

以上就是踏实白羊最近收集整理的关于力扣------合并两个有序链表的全部内容,更多相关力扣------合并两个有序链表内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(99)

评论列表共有 0 条评论

立即
投稿
返回
顶部