Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Autosaved
Table of Contents
stylenone

遍历二维数组

LC 151. Reverse Words in a String 反转字符串中的单词

https://leetcode.com/problems/reverse-words-in-a-string/

Code Block
languagego
func reverseWords(s string) string {
    words := strings.Fields(s)
    slices.Reverse(words)
    return strings.Join(words, " ")
}

...