Merge pull request #75 from QuinnDK/添加0090子集IIGo版本-1

添加0090子集IIGo版本
This commit is contained in:
Carl Sun
2021-05-13 21:16:56 +08:00
committed by GitHub

View File

@ -211,7 +211,30 @@ Python
Go Go
```Go
var res[][]int
func subsetsWithDup(nums []int)[][]int {
res=make([][]int,0)
sort.Ints(nums)
dfs([]int{},nums,0)
return res
}
func dfs(temp, num []int, start int) {
tmp:=make([]int,len(temp))
copy(tmp,temp)
res=append(res,tmp)
for i:=start;i<len(num);i++{
if i>start&&num[i]==num[i-1]{
continue
}
temp=append(temp,num[i])
dfs(temp,num,i+1)
temp=temp[:len(temp)-1]
}
}
```