Java


  • 0
    N
    public class Solution {
        public String reverseWords(String s) {
        	String res = "";
            String[] strings = s.split(" ");
            for (String string : strings) {
    			string = new StringBuffer(string).reverse().toString();
    			res += string + " ";
    		}
            return res.substring(0, res.length()-1);
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.