Update solution 0541

This commit is contained in:
halfrost
2021-11-07 01:15:26 -08:00
committed by halfrost
parent fcc3d10ff1
commit df54373ba8
3 changed files with 14 additions and 2 deletions

View File

@ -53,6 +53,18 @@ func reverseStr(s string, k int) string {
return s
}
func revers(s string) string {
bytes := []byte(s)
i, j := 0, len(bytes)-1
for i < j {
bytes[i], bytes[j] = bytes[j], bytes[i]
i++
j--
}
return string(bytes)
}
```