add: 220307 [cpp]

This commit is contained in:
Lam Haoyin 2022-03-07 08:17:02 +08:00
parent 4a761f21c6
commit d21d923526
No known key found for this signature in database
GPG Key ID: 8C089CB1A2B7544F
2 changed files with 15 additions and 0 deletions

8
cpp/2203/220307.cpp Normal file
View File

@ -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
*/

View File

@ -10,6 +10,13 @@ struct ListNode {
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 {
public:
static ListNode* mergeTwoLists(ListNode* list1, ListNode* list2) {