归并排序之链表的归并排序

题目:LeetCode - 148

要点:

1. 归并排序两个步骤:分开,融合

2.对于链表的分开,可以使用一个慢指针slow和一个快指针fast进行遍历,这样将slow的next赋为NULL,就分成了两个链表

进阶:

1.从顶至底的排序需要logn的递归空间,使用迭代方法,从底至顶进行切割,将空间复杂度变为O(1)

2.具体看:https://leetcode-cn.com/problems/sort-list/solution/li-yong-cyu-yan-shi-xian-cong-di-dao-ding-gui-bing/

posted @ 2020-12-03 11:26  重言  阅读(130)  评论(0)    收藏  举报