funcsubsets(nums[]int)[][]int{n:=len(nums)ans:=make([][]int,int(math.Pow(2,float64(n))))vartmp[]inttIdx:=0varbacktrackingfunc(idxint)backtracking=func(idxint){ifidx>=n{ans[tIdx]=append([]int(nil),tmp...)tIdx++return}else{// idx < n
tmp=append(tmp,nums[idx])backtracking(idx+1)tmp=tmp[:len(tmp)-1]backtracking(idx+1)}}backtracking(0)returnans}