class Solution:
# @param s, a string
# @return an integer
def lengthOfLastWord(self, s):
l=s.split(' ')
if len(l)==1:
return len(l[-1])
else:
for i in reversed(range(len(l))):
if l[i]!='':
return len(l[i])
return 0
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment