finish 58

This commit is contained in:
sangge 2024-03-09 04:24:15 +08:00
parent d0633f9292
commit 211fcd1dfa

11
leetcode/58.py Normal file
View File

@ -0,0 +1,11 @@
"""
Given a string s consisting of words and spaces,
return the length of the last word in the string.
A word is a maximal substring consisting of non-space characters only.
"""
class Solution:
def lengthOfLastWord(self, s: str) -> int:
s = s.strip()
s = s.split(" ")
return len(s[-1])