{"id":135,"date":"2017-08-28T20:31:50","date_gmt":"2017-08-28T12:31:50","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=135"},"modified":"2018-11-27T16:32:39","modified_gmt":"2018-11-27T08:32:39","slug":"108-convert-sorted-array-to-binary-search-tree","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=135","title":{"rendered":"108. Convert Sorted Array to Binary Search Tree"},"content":{"rendered":"<p>Given an array where elements are sorted in ascending order, convert it to a height balanced BST.<\/p>\n<p>For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of\u00a0<em>every<\/em>\u00a0node never differ by more than 1.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre>Given the sorted array: [-10,-3,0,5,9],\r\n\r\nOne possible answer is: [0,-3,9,-10,null,5], which represents the following height balanced BST:\r\n\r\n      0\r\n     \/ \\\r\n   -3   9\r\n   \/   \/\r\n -10  5<\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> \r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Given an array where elements are sorted in ascending o<a href=\"https:\/\/www.ccagml.com\/?p=135\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">108. Convert Sorted Array to Binary Search Tree<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29,20],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/135"}],"collection":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=135"}],"version-history":[{"count":1,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/135\/revisions"}],"predecessor-version":[{"id":136,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/135\/revisions\/136"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}