Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
有序的數組轉換成高度平衡的二叉排序樹。
代碼:
參考代碼
中間的節點作為根節點,左邊的節點是left和mid-1的中間的節點,右邊的節點類似。
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
有序的數組轉換成高度平衡的二叉排序樹。
中間的節點作為根節點,左邊的節點是left和mid-1的中間的節點,右邊的節點類似。