LeetCode OJ: Reverse Words in a String

Following is a simple solution to the LeetCode's Reverse Words in a String problem.

def reverseWords(s: String) = 
  s.split (" ")
   .reverse
   .mkString(" ")

Lets execute it in the REPL.

scala> reverseWords("the sky is blue")
res14: String = blue is sky the