Java Solution with Regular expression and Split() Method

programming
amazon
interview-questions
facebook
Tags: #<Tag:0x00007f2425dec1c8> #<Tag:0x00007f2425dec060> #<Tag:0x00007f2425db7e78> #<Tag:0x00007f2425db7d38>

#1
public class Solution {
    public String solve(String A) {
        if(A.length() == 0) return A;
        String[] strings = A.split("\\s+");
        String t = "";
        for(int i = strings.length - 1; i > -1; i--) {
            t += strings[i] + " ";
        }
        return t.trim();
    }
}