Merge pull request #68 from QuinnDK/添加0344反转字符串Go版本

添加0344反转字符串 Go版本
This commit is contained in:
Carl Sun
2021-05-13 17:30:20 +08:00
committed by GitHub
2 changed files with 33 additions and 0 deletions

View File

@ -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:

View File

@ -160,6 +160,17 @@ Python
Go
```Go
func reverseString(s []byte) {
left:=0
right:=len(s)-1
for left<right{
s[left],s[right]=s[right],s[left]
left++
right--
}
}
```