class Solution {
public String reverseWords(String s) {
Deque<String> stack = new ArrayDeque<>(0);
String[] split = s.split(" ");
for (String item : split) {
stack.push(item);
}
StringBuilder stringBuilder = new StringBuilder();
while(!stack.isEmpty()) {
String pop = stack.pop();
stringBuilder.append(pop).append(" ");
}
return stringBuilder.substring(0, stringBuilder.length() - 1);
}
}