码迷,mamicode.com
首页 > 其他好文 > 详细

leetcode——58. 最后一个单词的长度

时间:2019-10-16 21:38:57      阅读:64      评论:0      收藏:0      [点我收藏+]

标签:ret   mda   长度   内存   ash   pytho   word   span   style   

class Solution:
    def lengthOfLastWord(self, s: str) -> int:
        if s== *len(s):
            return 0
        if   not in s:
            return len(s)
        a=s.split( )
        i=-1
        while a[i]==‘‘:
            i-=1
        return len(a[i])
执行用时 :44 ms, 在所有 python3 提交中击败了78.73%的用户
内存消耗 :13.6 MB, 在所有 python3 提交中击败了5.01%的用户
 
                                               ——2019.10.16

leetcode——58. 最后一个单词的长度

标签:ret   mda   长度   内存   ash   pytho   word   span   style   

原文地址:https://www.cnblogs.com/taoyuxin/p/11688537.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!