fix(go): record slice array result, fixed #1075 (#1087)

pull/1089/head
Reanon 9 months ago committed by GitHub
parent e813b5a0fa
commit e9341c51b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -18,7 +18,7 @@ func preOrderIII(root *TreeNode, res *[][]*TreeNode, path *[]*TreeNode) {
*path = append(*path, root) *path = append(*path, root)
if root.Val.(int) == 7 { if root.Val.(int) == 7 {
// 记录解 // 记录解
*res = append(*res, *path) *res = append(*res, append([]*TreeNode{}, *path...))
} }
preOrderIII(root.Left, res, path) preOrderIII(root.Left, res, path)
preOrderIII(root.Right, res, path) preOrderIII(root.Right, res, path)

@ -15,7 +15,7 @@ func isSolution(state *[]*TreeNode) bool {
/* 记录解 */ /* 记录解 */
func recordSolution(state *[]*TreeNode, res *[][]*TreeNode) { func recordSolution(state *[]*TreeNode, res *[][]*TreeNode) {
*res = append(*res, *state) *res = append(*res, append([]*TreeNode{}, *state...))
} }
/* 判断在当前状态下,该选择是否合法 */ /* 判断在当前状态下,该选择是否合法 */

Loading…
Cancel
Save