A simple and esay python Solution


  • -1
    V

    class Solution(object):
    def reverseWords(self, s):
    """
    :type s: str
    :rtype: str
    """
    tmp = s.split(" ")
    res = ""
    for i in range(len(tmp)):
    item = tmp[i][::-1]
    if i == len(tmp) - 1:
    res = res + item
    else :
    res = res + item + " "
    return res


Log in to reply
 

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