Python 45 chars , 1 line solution


  • 0
    F

    This problem begs to count the # chars not the lines.

    class Solution(object):
        def reverseWords(self, s):
            """
            :type s: str
            :rtype: str
            """
            return " ".join([s[::-1] for s in a.split()])
    

  • 1

    If you want to optimize for #chars, you could use a generator expression (and omit its parentheses) instead of a list comprehension.


Log in to reply
 

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