Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
給定一個已排序的數組(不存在重複元素),将它轉換成一棵平衡二叉搜尋樹。
由于平衡二叉樹要求左右子樹的高度差絕對值相遇等于1,也就是說左右子樹盡可能包含相同數目節點。
則使用二分法來解本題即可。
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
給定一個已排序的數組(不存在重複元素),将它轉換成一棵平衡二叉搜尋樹。
由于平衡二叉樹要求左右子樹的高度差絕對值相遇等于1,也就是說左右子樹盡可能包含相同數目節點。
則使用二分法來解本題即可。