Loading...
Engaged Employer
reverse a string, then reverse a sentence
Anonymous
1. swap position 1 - n, 2 - (n-1), ... 2. previous step and called again for every word every time a word delimiter is found.
1) reverse a string: public static String reverse(String str) { StringBuilder revStr = new StringBuilder(""); for (int i = str.length()-1; i >= 0; i--) { revStr.append(str.charAt(i)); } return revStr.toString(); } 2) Reverse a sentence: public static String reverseSentance(String str) { StringBuilder revStr = new StringBuilder(""); String[] arr = str.split(" "); for (int i = arr.length-1; i >= 0; i--) { revStr.append(arr[i] + " "); } return revStr.toString(); }
Check out your Company Bowl for anonymous work chats.
Get actionable career advice tailored to you by joining more bowls.
Stay ahead in opportunities and insider tips by following your dream companies.
Get personalized job recommendations and updates by starting your searches.