ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# [557\. 反转字符串中的单词 III](https://leetcode-cn.com/problems/reverse-words-in-a-string-iii/) ![](https://box.kancloud.cn/a8e22faeda1a116543e4139cd7309671_632x145.png) ### 解法1 ``` func reverseWords(s string) string { data := "" split := strings.Split(s, " ") end := len(split)-1 for k,v := range split { i := desc(v) if k != end { data += i + " " }else{ data += i } } return data } func desc(s string) string { data := "" for i:=len(s)-1;i>=0;i-- { data += string(s[i]) } return data } ``` ### 解法二