The problem is to reverse the order of words in a string. That is, given the sky is blue , the expected output is blue is sky the . However, the original problem on Leetcode specifically asks you to do it in-place without allocating extra space.
Problem Statment: Write a recursive function to reverse a string. Write a recursiveunction to reverse the words in a string, i.e., "cat is running" becomes "running is cat". Write a recursiveunction to reverse the words in a string, i.e., "cat is running" becomes "running is cat". If we wanted to reverse the order, we could exchange the sort() for a reverse() ... public final class String implements java.io.Serializable, Comparable<String>, CharSequence { ...