###108. Convert Sorted Array to Binary Search Tree

题目:
<https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/>


难度:
Medium


思路：

递归

- nums为空，return None
- nums 只有一个， return其为根节点
- nums 大于一个，nums[n/2]为中间元素，根结点，nums[:mid]为左子树， nums[mid+1:]为右子树


```
class Solution(object):
	def sortedArrayToBST(self, nums):
		"""
		:type nums: List[int]
		:rtype: TreeNode
		"""
		n = len(nums)

		if n == 0 :
			return None
		if n == 1 :
			return TreeNode(nums[0])
		else:
			mid = n / 2
			root = TreeNode(nums[mid])
			root.left = self.sortedArrayToBST(nums[:mid])
			root.right = self.sortedArrayToBST(nums[mid+1:])
			return root


```
