规范格式

This commit is contained in:
YDZ
2020-08-07 15:50:06 +08:00
parent 854a339abc
commit 4e11f4028a
1438 changed files with 907 additions and 924 deletions

View File

@ -0,0 +1,24 @@
package leetcode
import (
"strings"
)
func reverseWords(s string) string {
ss := strings.Split(s, " ")
for i, s := range ss {
ss[i] = revers(s)
}
return strings.Join(ss, " ")
}
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)
}