Skip to content

Commit ff6679c

Browse files
committed
Create README - LeetHub
1 parent f3fed6f commit ff6679c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<h2><a href="https://leetcode.com/problems/balance-a-binary-search-tree">1382. Balance a Binary Search Tree</a></h2><h3>Medium</h3><hr><p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
2+
3+
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every node never differs by more than <code>1</code>.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
<img alt="" src="https://assets.leetcode.com/uploads/2021/08/10/balance1-tree.jpg" style="width: 500px; height: 319px;" />
8+
<pre>
9+
<strong>Input:</strong> root = [1,null,2,null,3,null,4,null,null]
10+
<strong>Output:</strong> [2,1,3,null,null,null,4]
11+
<b>Explanation:</b> This is not the only correct answer, [3,1,4,null,2] is also correct.
12+
</pre>
13+
14+
<p><strong class="example">Example 2:</strong></p>
15+
<img alt="" src="https://assets.leetcode.com/uploads/2021/08/10/balanced2-tree.jpg" style="width: 224px; height: 145px;" />
16+
<pre>
17+
<strong>Input:</strong> root = [2,1,3]
18+
<strong>Output:</strong> [2,1,3]
19+
</pre>
20+
21+
<p>&nbsp;</p>
22+
<p><strong>Constraints:</strong></p>
23+
24+
<ul>
25+
<li>The number of nodes in the tree is in the range <code>[1, 10<sup>4</sup>]</code>.</li>
26+
<li><code>1 &lt;= Node.val &lt;= 10<sup>5</sup></code></li>
27+
</ul>

0 commit comments

Comments
 (0)