mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
Merge branch 'master' of https://github.com/youngyangyang04/leetcode
This commit is contained in:
@ -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]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ Java:
|
|||||||
|
|
||||||
Python:
|
Python:
|
||||||
|
|
||||||
|
Go:
|
||||||
```Go
|
```Go
|
||||||
func invertTree(root *TreeNode) *TreeNode {
|
func invertTree(root *TreeNode) *TreeNode {
|
||||||
if root ==nil{
|
if root ==nil{
|
||||||
|
Reference in New Issue
Block a user