scala version


  • 0
    M
      def reverseWords(str: String): String = {
        var arr = str.split(" ", -1)
        for (i <- arr.indices) {
          arr(i) = arr(i).reverse
        }
        arr.mkString(" ")
      }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.