Java 3-liner


  • 0
    S
    public String reverseWords(String s) {
        List<String> l = Arrays.asList(s.split(" "));
        l.replaceAll(str->new StringBuilder(str).reverse().toString());
        return String.join(" ", l);
    }

Log in to reply
 

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