1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-11 10:21:43 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/有序链表转换二叉搜索树 [convert-sorted-list-to-binary-search-tree].html
2025-01-09 20:29:41 +08:00

30 lines
966 B
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给定一个单链表的头节点 &nbsp;<code>head</code>&nbsp;,其中的元素 <strong>按升序排序</strong> ,将其转换为 <span data-keyword="height-balanced">平衡</span> 二叉搜索树。</p>
<p>&nbsp;</p>
<p><strong>示例 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/08/17/linked.jpg" style="height: 388px; width: 500px;" /></p>
<pre>
<strong>输入:</strong> head = [-10,-3,0,5,9]
<strong>输出:</strong> [0,-3,9,-10,null,5]
<strong>解释:</strong> 一个可能的答案是[0-3,9-10,null,5],它表示所示的高度平衡的二叉搜索树。
</pre>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入:</strong> head = []
<strong>输出:</strong> []
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>head</code>&nbsp;中的节点数在<code>[0, 2 * 10<sup>4</sup>]</code>&nbsp;范围内</li>
<li><code>-10<sup>5</sup>&nbsp;&lt;= Node.val &lt;= 10<sup>5</sup></code></li>
</ul>