Reverse Words in String II Problem

Reverse Words in String II Problem — ExecCode School DSA Practice

Solve the Reverse Words in String II problem on ExecCode. Free online school DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

You are given a sentence. Your task is to reverse the order of the words in the sentence. For example, if the sentence is "the sky is blue", you should print "blue is sky the". Print the sentence with the words in their new, reversed order.

Examples

Input the sky is blue; Output blue is sky the. Input a good example; Output example good a

Constraints

1 <= s.length <= 10^5

Practice Reverse Words in String II free on ExecCode. Browse DSA problems, topic map, and placement guides.