Python solution


  • 0
    S
        if s == '':
            return ''
            
        temp = s.split(' ')
        res = ''
        x = temp[::-1]
        mp = map(lambda x: x.strip(), x)
        for i in range(len(x)):
            if mp[i] == "":
                continue
            else:
                res += mp[i] + " "
    
        return res.strip()

Log in to reply
 

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