Skip to content

Commit 7228a03

Browse files
committed
Create README - LeetHub
1 parent 999c9a6 commit 7228a03

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Diff for: balance-a-binary-search-tree/README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<h2>1382. Balance a Binary Search Tree</h2><h3>Medium</h3><hr><div><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>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><strong>Input:</strong> root = [1,null,2,null,3,null,4,null,null]
9+
<strong>Output:</strong> [2,1,3,null,null,null,4]
10+
<b>Explanation:</b> This is not the only correct answer, [3,1,4,null,2] is also correct.
11+
</pre>
12+
13+
<p><strong>Example 2:</strong></p>
14+
<img alt="" src="https://assets.leetcode.com/uploads/2021/08/10/balanced2-tree.jpg" style="width: 224px; height: 145px;">
15+
<pre><strong>Input:</strong> root = [2,1,3]
16+
<strong>Output:</strong> [2,1,3]
17+
</pre>
18+
19+
<p>&nbsp;</p>
20+
<p><strong>Constraints:</strong></p>
21+
22+
<ul>
23+
<li>The number of nodes in the tree is in the range <code>[1, 10<sup>4</sup>]</code>.</li>
24+
<li><code>1 &lt;= Node.val &lt;= 10<sup>5</sup></code></li>
25+
</ul>
26+
</div>

0 commit comments

Comments
 (0)