Given an input string, reverse the string word by word.A word is defined as a sequence of non-space characters.Input string may contain leading or trailing spaces. However, your reversed string should not contain leading or trailing spaces.You need to reduce multiple spaces between two words to a single space in the reversed string.
Examples
1 2 3
Example 1: Input: "the sky is blue", Output: "blue is sky the".
int resultSize = list.size(); if (limit == 0) {//controls the number of times the pattern is applied // limit = n : The pattern is applied n-1 times,limit = 0 :the pattern will be applied as many times as possible while (resultSize > 0 && list.get(resultSize - 1).length() == 0) { resultSize--; } } String[] result = new String[resultSize]; return list.subList(0, resultSize).toArray(result);