1 line Java solution


  • 0
    I
    public String reverseWords(String s) {
            return Arrays.stream(s.split(" "))
                         .map(str -> new StringBuilder(str).reverse().toString())
                         .collect(Collectors.joining(" "));
    }
    

Log in to reply
 

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