add: 220307 [cpp]
This commit is contained in:
parent
4a761f21c6
commit
d21d923526
|
|
@ -0,0 +1,8 @@
|
||||||
|
/**
|
||||||
|
* 21. Merge Two Sorted Lists
|
||||||
|
* You are given the heads of two sorted linked lists list1 and list2.
|
||||||
|
* Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists.
|
||||||
|
* Return the head of the merged linked list.
|
||||||
|
*
|
||||||
|
* Refer: more/0021.cpp
|
||||||
|
*/
|
||||||
|
|
@ -10,6 +10,13 @@ struct ListNode {
|
||||||
explicit ListNode(int x = 0, ListNode* next = nullptr) : val(x), next(next) {}
|
explicit ListNode(int x = 0, ListNode* next = nullptr) : val(x), next(next) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 21. Merge Two Sorted Lists
|
||||||
|
* You are given the heads of two sorted linked lists list1 and list2.
|
||||||
|
* Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists.
|
||||||
|
* Return the head of the merged linked list.
|
||||||
|
*/
|
||||||
|
|
||||||
class Solution {
|
class Solution {
|
||||||
public:
|
public:
|
||||||
static ListNode* mergeTwoLists(ListNode* list1, ListNode* list2) {
|
static ListNode* mergeTwoLists(ListNode* list1, ListNode* list2) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue