Golang solution ( beat 100% cpu & memory)
Pretty solution:\n\nfunc sortedArrayToBST(nums []int) *TreeNode {\n\tif len(nums) == 0 {\n\t\treturn nil\n\t}\n\ti := len(nums) / 2\n\troot := &TreeNode{Val: nu
Pretty solution:\n```\nfunc sortedArrayToBST(nums []int) *TreeNode {\n\tif len(nums) == 0 {\n\t\treturn nil\n\t}\n\ti := len(nums) / 2\n\troot := &TreeNode{Val: nums[i]}\n\troot.Left = sortedArrayToBST(nums[:i])\n\troot.Right = sortedArrayToBST(nums[i+1:])\n\treturn root\n}\n```\n\nbeat 100% cpu&mem:\n```\nfunc sortedArrayToBST(nums []int) *TreeNode {\n\tif len(nums) == 0 {\n\t\treturn nil\n\t}\n\ti := len(nums) / 2\n\troot := &TreeNode{Val: nums[i]}\n\tif i != 0 {\n\t\troot.Left = sortedArrayToBST(nums[:i])\n\t}\n\tif i != len(nums)-1 {\n\t\troot.Right = sortedArrayToBST(nums[i+1:])\n\t}\n\treturn root\n}\n```
['Go']