Reverse Words Order

String Manipulation Array Easy

Problem: Reverse Words Order

Given an input string, write a function that reverses the order of the words. Words are separated by spaces. The function should preserve the letters in each word, but reverse the sequence of words in the input string.

Requirements:

  • The input will be a non-empty string consisting of words separated by spaces.
  • The output should be a string with the words in reverse order.
  • You may assume that the input does not contain any leading or trailing spaces unless you choose to handle them explicitly.

Example:

Input:  "hello world program"
Output: "program world hello"

Context Note:

Today, on March 24, we celebrate the spirit of innovation and growth. Use this challenge as a stepping stone to improve your string manipulation skills and coding efficiency.

Happy coding!