Update 0090.子集II.md

This commit is contained in:
QuinnDK
2021-05-13 18:25:55 +08:00
committed by GitHub
parent bff058e3c0
commit d7296eb74b

View File

@ -178,7 +178,30 @@ Python
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]
}
}
```