diff --git a/exampleSite/content/post/2024-04-20七大排序算法/index.zh-cn.md b/exampleSite/content/post/2024-04-20七大排序算法/index.zh-cn.md index 985b445..c6e1dce 100644 --- a/exampleSite/content/post/2024-04-20七大排序算法/index.zh-cn.md +++ b/exampleSite/content/post/2024-04-20七大排序算法/index.zh-cn.md @@ -263,7 +263,30 @@ vector MySort(vector& arr) { [206. 反转链表](https://leetcode.cn/problems/reverse-linked-list/) ```cpp - +class Solution { +public: + // ListNode* reverseList(ListNode* head) { + // if(!head)return NULL; + // auto a = head,b = head->next; + // while(b) + // { + // auto c = b->next; + // b->next= a; + // a = b; + // b = c; + // } + // head->next = NULL; + // return a; + // } + ListNode * reverseList(ListNode * head) + { + if(!head || !head->next)return head; + auto tail = reverseList(head->next); + head->next->next = head; + head->next = NULL; + return tail; + } +}; ```