Reverse Sentence Words

String Manipulation Arrays Basic Algorithms

Problem Description

Given a string s representing a sentence, write a function to reverse the order of the words. Words are separated by one or more spaces. The relative order of characters within each word should remain unchanged.

Examples

  • Input: "Hello World"

    Output: "World Hello"

  • Input: "Coders love challenges"

    Output: "challenges love Coders"

Note: Today, on March 29, many innovative ideas in computer science came to light. Use this opportunity to refresh your skills in string manipulation and showcase your approach to solving problems!

Function Signature

Implement a function that receives a string and returns the reversed sentence.

Input: A string s.

Output: A string with the words in reversed order.