From c7bbec0bc0b8b3a639a8ecc3102fcd23c3613dcf Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Thu, 24 Feb 2022 01:24:21 -0800 Subject: [PATCH] 148 --- leetcode/148. Sort List/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/leetcode/148. Sort List/README.md b/leetcode/148. Sort List/README.md index fe49557e..7ff20c15 100644 --- a/leetcode/148. Sort List/README.md +++ b/leetcode/148. Sort List/README.md @@ -51,7 +51,7 @@ // Time: O(NlogN) // Space: O(logN) class Solution { - pair splitList(ListNode *head) { + ListNode* splitList(ListNode *head) { ListNode dummy, *p = &dummy, *q = &dummy; dummy.next = head; while (q && q->next) { @@ -60,7 +60,7 @@ class Solution { } auto next = p->next; p->next = NULL; - return {head, next}; + return next; } ListNode *mergeList(ListNode *a, ListNode *b) { ListNode head, *tail = &head; @@ -83,8 +83,8 @@ class Solution { public: ListNode* sortList(ListNode* head) { if (!head || !head->next) return head; - auto [a, b] = splitList(head); - return mergeList(sortList(a), sortList(b)); + auto b = splitList(head); + return mergeList(sortList(head), sortList(b)); } }; ```