Reverse Words in a String II
‘STR’ = “when in doubt use brute force” The reverse order of words in ‘STR’ is: “force brute use doubt in when”.
1. ‘STR’ does not contain any leading or trailing spaces. 2. The words are always separated by a single whitespace character.
The first line of input contains an integer ‘T’ which denotes the number of test cases. Then, the ‘T’ test cases follow. The first line and only line of each test case contain a single string ‘STR’.
For every test case, return a string with the reverse orders of words as ‘STR’.
You do not need to print anything; it has already been taken care of. Just implement the function.
1 <= T <= 100 1 <= Length of ‘STR’ <= 10^3 The string ‘STR’ contains only ‘a-z’ and whitespace characters. Time limit: 1 second
Ninja and Numbers
Longest Palindromic Substring