344.reverse-string.go 148 B

123456789
  1. func reverseString(s string) string {
  2. n := len(s)
  3. runes := make([]rune, n)
  4. for _, r := range s {
  5. n--
  6. runes[n] = r
  7. }
  8. return string(runes)
  9. }