58. Length of Last Word
Содержание
class Solution:
def lengthOfLastWord(self, s: str) -> int:
i = len(s) - 1
while i >= 0 and s[i] == ' ':
i -= 1
j = i
while j >= 0 and s[j] != ' ':
j -= 1
return i - j
class Solution:
def lengthOfLastWord(self, s: str) -> int:
ar = s.split()
return len(ar[-1])