ai-week/tools/algorithm.go

13 lines
199 B
Go

package tools
// 反转切片
func ReverseSlice(s []string) []string {
length := len(s)
reversed := make([]string, length)
for i, v := range s {
reversed[length-i-1] = v
}
return reversed
}