From d21d923526f5ff336798c5ecef17bb9caa22b030 Mon Sep 17 00:00:00 2001 From: Lam Haoyin Date: Mon, 7 Mar 2022 08:17:02 +0800 Subject: [PATCH] add: 220307 [cpp] --- cpp/2203/220307.cpp | 8 ++++++++ cpp/more/0021.cpp | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 cpp/2203/220307.cpp diff --git a/cpp/2203/220307.cpp b/cpp/2203/220307.cpp new file mode 100644 index 0000000..1d07210 --- /dev/null +++ b/cpp/2203/220307.cpp @@ -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 + */ \ No newline at end of file diff --git a/cpp/more/0021.cpp b/cpp/more/0021.cpp index 2866171..352226b 100644 --- a/cpp/more/0021.cpp +++ b/cpp/more/0021.cpp @@ -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) {