/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/funcsortedArrayToBST(nums[]int)*TreeNode{iflen(nums)==0{returnnil}iflen(nums)==1{return&TreeNode{Val:nums[0]}}mid:=len(nums)/2root:=&TreeNode{Val:nums[mid]}root.Left=sortedArrayToBST(nums[0:mid])root.Right=sortedArrayToBST(nums[mid+1:len(nums)])returnroot}