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