diff --git a/problems/0046.全排列.md b/problems/0046.全排列.md index 805bc457..c437f7ca 100644 --- a/problems/0046.全排列.md +++ b/problems/0046.全排列.md @@ -275,29 +275,34 @@ class Solution: ### Go ```Go -var res [][]int +var ( + res [][]int + path []int + st []bool // state的缩写 +) func permute(nums []int) [][]int { - res = [][]int{} - backTrack(nums,len(nums),[]int{}) - return res -} -func backTrack(nums []int,numsLen int,path []int) { - if len(nums)==0{ - p:=make([]int,len(path)) - copy(p,path) - res = append(res,p) - } - for i:=0;i