首页
软件开发
登录
6mi
u
盘
搜
搜 索
软件开发
python写算法题:leetcode: 58. Length of Last Word
python写算法题:leetcode: 58. Length of Last Word
xiaoxiao
2025-08-23
6
class Solution(object): def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ ret=0 lastch = len(s)-1 for _ in xrange(len(s)): if (s[lastch]==' '): lastch-=1 for ind in xrange(lastch+1): if (s[lastch-ind]==' '): return ind return lastch+1
转载请注明原文地址: https://yun.8miu.com/read-140421.html
最新回复
(
0
)