瀏覽代碼

update helper

dengxinyi 6 年之前
父節點
當前提交
e56c504ebf
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      hard/helper.go

+ 3 - 3
hard/helper.go

@@ -86,7 +86,7 @@ func printList(head *ListNode) {
 	println()
 }
 
-func toBST(nums []int) *TreeNode {
+func sortedToBST(nums []int) *TreeNode {
 	if len(nums) == 0 {
 		return nil
 	}
@@ -96,8 +96,8 @@ func toBST(nums []int) *TreeNode {
 	if mid == 0 {
 		return &root
 	}
-	root.Left = toBST(nums[:mid])
-	root.Right = toBST(nums[mid+1:])
+	root.Left = sortedToBST(nums[:mid])
+	root.Right = sortedToBST(nums[mid+1:])
 	return &root
 }