diff --git a/problems/0078.子集.md b/problems/0078.子集.md index a61d7493..7166f7fa 100644 --- a/problems/0078.子集.md +++ b/problems/0078.子集.md @@ -209,6 +209,28 @@ Python: Go: +```Go +var res [][]int +func subset(nums []int) [][]int { + res = make([][]int, 0) + sort.Ints(nums) + Dfs([]int{}, nums, 0) + return res +} +func Dfs(temp, nums []int, start int){ + tmp := make([]int, len(temp)) + copy(tmp, temp) + res = append(res, tmp) + for i := start; i < len(nums); i++{ + //if i>start&&nums[i]==nums[i-1]{ + // continue + //} + temp = append(temp, nums[i]) + Dfs(temp, nums, i+1) + temp = temp[:len(temp)-1] + } +} +``` Javascript: diff --git a/problems/0344.反转字符串.md b/problems/0344.反转字符串.md index 02282355..b4c843b7 100644 --- a/problems/0344.反转字符串.md +++ b/problems/0344.反转字符串.md @@ -160,6 +160,17 @@ Python: Go: +```Go +func reverseString(s []byte) { + left:=0 + right:=len(s)-1 + for left