@@ -0,0 +1,893 @@
+package net.morphism.training;%0A%0Aimport java.util.Hashtable;%0A%0Apublic class ReverseWords %7B%0A%09%0A%09public static String solution(final String inputString) %7B%0A%09%0A%09%09inputString = inputString.trim();%0A%09%09String%5B%5D words = inputString.split(%22 %22);%0A%0A%09%09int numberOfWords = words.length;%0A%09%09%0A%09%09Hashtable%3CInteger,String%3E H = new Hashtable%3CInteger,String%3E();%0A%09%09int pivot = numberOfWords -1;%0A%09%09int key = 0;%0A%0A        // Add non-empty words in inverse order to Hashtable H from String%5B%5D words.%0A%09%09while(pivot%3E=0 && key %3C numberOfWords) %7B%0A%09%09%09if(!words%5Bpivot%5D.isEmpty()) %7B%0A%09%09%09%09H.put(key, words%5Bpivot%5D);%0A%09%09%09%09key++; pivot--;%0A%09%09%09%7D%0A%09%09%09else %7B%0A%09%09%09%09pivot--;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09// Append elements of Hashtable H to StringBuffer buffer, separated with a space.%0A%09%09StringBuffer buffer = new StringBuffer();%0A%09%09for (int i=0; i%3C H.size(); i++) %7B%0A%09%09%09buffer.append(H.get(i));%0A%09%09%09buffer.append(%22 %22);%0A%09%09%7D%0A%09%09return buffer.toString().trim();%0A%09%7D%0A%7D%0A

Create ReverseWords.java