Skip to content

Commit 0550e92

Browse files
committed
Create README - LeetHub
1 parent b38005f commit 0550e92

File tree

1 file changed

+29
-0
lines changed
  • convert-sorted-array-to-binary-search-tree

1 file changed

+29
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<h2>108. Convert Sorted Array to Binary Search Tree</h2><h3>Easy</h3><hr><div><p>Given an integer array <code>nums</code> where the elements are sorted in <strong>ascending order</strong>, convert <em>it to a <strong>height-balanced</strong> binary search tree</em>.</p>
2+
3+
<p>A <strong>height-balanced</strong> binary tree is a binary tree in which the depth of the two subtrees of every node never differs by more than one.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong>Example 1:</strong></p>
7+
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/18/btree1.jpg" style="width: 302px; height: 222px;">
8+
<pre><strong>Input:</strong> nums = [-10,-3,0,5,9]
9+
<strong>Output:</strong> [0,-3,9,-10,null,5]
10+
<strong>Explanation:</strong> [0,-10,5,null,-3,null,9] is also accepted:
11+
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/18/btree2.jpg" style="width: 302px; height: 222px;">
12+
</pre>
13+
14+
<p><strong>Example 2:</strong></p>
15+
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/18/btree.jpg" style="width: 342px; height: 142px;">
16+
<pre><strong>Input:</strong> nums = [1,3]
17+
<strong>Output:</strong> [3,1]
18+
<strong>Explanation:</strong> [1,3] and [3,1] are both a height-balanced BSTs.
19+
</pre>
20+
21+
<p>&nbsp;</p>
22+
<p><strong>Constraints:</strong></p>
23+
24+
<ul>
25+
<li><code>1 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
26+
<li><code>-10<sup>4</sup> &lt;= nums[i] &lt;= 10<sup>4</sup></code></li>
27+
<li><code>nums</code> is sorted in a <strong>strictly increasing</strong> order.</li>
28+
</ul>
29+
</div>

0 commit comments

Comments
 (0)