python one liner


  • 0
    R
    class Solution(object):
        def lengthOfLastWord(self, s):
            """
            :type s: str
            :rtype: int
            """
            return list(map(lambda i: len(i),s.strip().split(" ")))[-1]
    

  • 1
    L

    return len(s.strip().split(" ")[-1]) would be sufficient.


Log in to reply
 

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