[Solved] Reverse The Words In A Sentence But Not The Letters [duplicate]
class Solution { public String reverseWords(String s) { if (s == null || s.length() == 0) { return “”; } // split to words by space String[] arr = s.split(” “); StringBuilder sb = new StringBuilder(); for (int i = arr.length – 1; i >= 0; –i) { if (!arr[i].equals(“”)) { sb.append(arr[i]).append(” “); } } … Read more