ds-algo-study
Version:
Just experimenting with publishing a package
34 lines (31 loc) • 1.59 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="A description of the page and its contents"
/>
<link rel="stylesheet" href="styles.css" />
<title>Page Title</title>
<link rel="stylesheet" href="./../../../assets/style.css" />
<link rel="stylesheet" href="./../../../assets/prism.css" />
<script async src="./../../../assets/prism.js"></script>
</head>
<body>
<h1 id="convert-sorted-array-to-binary-search-tree">Convert Sorted Array to Binary Search Tree</h1>
<blockquote>
<p>Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.</p>
</blockquote>
<p>Given an array where elements are sorted in ascending order, convert it to a height balanced BST.</p>
<p>For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of <em>every</em> node never differ by more than 1.</p>
<p><strong>Example:</strong></p>
<p>Given the sorted array: [-10,-3,0,5,9],</p>
<p>One possible answer is: [0,-3,9,-10,null,5], which represents the following height balanced BST:</p>
pre data-role="codeBlock" data-info="js" class="language-javascript"><code> 0
/ \\</code></pre>
<p>-3 9 / / -10 5</p>
<p><a class="btn" href="https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/">Source</a></p>
</body>
</html>