Reverse Words in a Sentence
Easyjavapythonccppjavascript
Given a sentence, reverse the order of its words without reversing the characters inside each word.
Input Format
A single line containing words separated by single spaces, with no leading or trailing spaces.
Output Format
Print the sentence with its words in reverse order, separated by single spaces.
Example 1
Input
I love coding
Output
coding love I
Explanation: Only the order of the words changes.
- 1 <= length of S <= 100000
- Words are separated by exactly one space.
Submit an attempt to unlock the solution. (Sign in first.)
Related Problems
- Reverse a StringEasy · java, python, c, cpp, javascriptSolve Problem
- Check PalindromeEasy · java, python, c, cpp, javascriptSolve Problem
- Count Vowels and ConsonantsEasy · java, python, c, cpp, javascriptSolve Problem