Reverse Words in a String III Solutions in GoNumber 557Difficulty EasyAcceptance 70.0%Link LeetCodeOther languages C++SolutionsGo solution by halfrost/LeetCode-Gopackage 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)}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) }