finish 58
This commit is contained in:
parent
d0633f9292
commit
211fcd1dfa
11
leetcode/58.py
Normal file
11
leetcode/58.py
Normal 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])
|
Loading…
x
Reference in New Issue
Block a user