mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 07:21:40 +08:00
update
This commit is contained in:
34
leetcode/problem/sort-list.html
Normal file
34
leetcode/problem/sort-list.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<p>Given the <code>head</code> of a linked list, return <em>the list after sorting it in <strong>ascending order</strong></em>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<img alt="" src="https://assets.leetcode.com/uploads/2020/09/14/sort_list_1.jpg" style="width: 450px; height: 194px;" />
|
||||
<pre>
|
||||
<strong>Input:</strong> head = [4,2,1,3]
|
||||
<strong>Output:</strong> [1,2,3,4]
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
<img alt="" src="https://assets.leetcode.com/uploads/2020/09/14/sort_list_2.jpg" style="width: 550px; height: 184px;" />
|
||||
<pre>
|
||||
<strong>Input:</strong> head = [-1,5,3,4,0]
|
||||
<strong>Output:</strong> [-1,0,3,4,5]
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> head = []
|
||||
<strong>Output:</strong> []
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li>The number of nodes in the list is in the range <code>[0, 5 * 10<sup>4</sup>]</code>.</li>
|
||||
<li><code>-10<sup>5</sup> <= Node.val <= 10<sup>5</sup></code></li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Follow up:</strong> Can you sort the linked list in <code>O(n logn)</code> time and <code>O(1)</code> memory (i.e. constant space)?</p>
|
Reference in New Issue
Block a user