Skip to content

Latest commit

 

History

History
23 lines (11 loc) · 486 Bytes

sort-list.md

File metadata and controls

23 lines (11 loc) · 486 Bytes

Sort List

描述

Sort a linked list in O(n log n) time using constant space complexity.

分析

常数空间且O(nlogn),单链表适合用归并排序,双向链表适合用快速排序。本题可以复用 Merge Two Sorted Lists 的代码。

代码

{% if book.cpp %} {% codesnippet "./code/sort-list.cpp", language="cpp" %}{% endcodesnippet %} {% endif %}

相关题目