Answers for "reverse a string in golang"

Go
2

reverse a string in golang

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}
Posted by: Guest on May-19-2020

Browse Popular Code Answers by Language