Write a function that reverses a string. The input string is given as an array of characters s
.
Write a function that reverses a string. The input string is given as an array of characters s
.
Solution in Go
func reverseString(s []byte) {
for i := 0; i < len(s) / 2; i++ {
s[i], s[len(s) - 1 - i] = s[len(s) - 1 - i], s[i]
}
}
Get notified once/twice per month when new articles are published.