Skip to content

Commit

Permalink
Time: 4 ms (32.1%), Space: 6.1 MB (18.51%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
hovanhoa committed Dec 13, 2024
1 parent d794235 commit 4bbfec3
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ func buildTree(preorder []int, inorder []int) *TreeNode {
root := &TreeNode{Val: preorder[0]}
i := slices.Index(inorder, preorder[0])
root.Left = buildTree(preorder[1:1+i], inorder[:i])
root.Right = buildTree(preorder[1+i:], inorder[i+1:])
root.Right = buildTree(preorder[i+1:], inorder[i+1:])
return root
}

0 comments on commit 4bbfec3

Please sign in to comment.