mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-24 22:38:57 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一棵二叉搜索树,请你返回一棵 <strong>平衡后</strong> 的二叉搜索树,新生成的树应该与原来的树有着相同的节点值。如果有多种构造方法,请你返回任意一种。</p>\n\n<p>如果一棵二叉搜索树中,每个节点的两棵子树高度差不超过 <code>1</code> ,我们就称这棵二叉搜索树是 <strong>平衡的</strong> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<p><img src=\"https://assets.leetcode.com/uploads/2021/08/10/balance1-tree.jpg\" style=\"height: 319px; width: 500px;\" /></p>\n\n<pre>\n<strong>输入:</strong>root = [1,null,2,null,3,null,4,null,null]\n<strong>输出:</strong>[2,1,3,null,null,null,4]\n<strong>解释:</strong>这不是唯一的正确答案,[3,1,4,null,2,null,null] 也是一个可行的构造方案。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<p><img src=\"https://assets.leetcode.com/uploads/2021/08/10/balanced2-tree.jpg\" style=\"height: 145px; width: 224px;\" /></p>\n\n<pre>\n<strong>输入:</strong> root = [2,1,3]\n<strong>输出:</strong> [2,1,3]\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li>树节点的数目在 <code>[1, 10<sup>4</sup>]</code> 范围内。</li>\n\t<li><code>1 <= Node.val <= 10<sup>5</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 104,
|
||||
"likes": 110,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -167,7 +167,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"13.9K\", \"totalSubmission\": \"19.6K\", \"totalAcceptedRaw\": 13881, \"totalSubmissionRaw\": 19622, \"acRate\": \"70.7%\"}",
|
||||
"stats": "{\"totalAccepted\": \"14.3K\", \"totalSubmission\": \"20.3K\", \"totalAcceptedRaw\": 14307, \"totalSubmissionRaw\": 20259, \"acRate\": \"70.6%\"}",
|
||||
"hints": [
|
||||
"Convert the tree to a sorted array using an in-order traversal.",
|
||||
"Construct a new balanced tree from the sorted array recursively."
|
||||
|
||||
Reference in New Issue
Block a user