58. Length of Last Word
https://leetcode.com/problems/length-of-last-word
Python
class Solution:
def lengthOfLastWord(self, s: str) -> int:
last_word = s.strip().split(' ').pop()
return len(last_word) if last_word != '' else 0
https://leetcode.com/problems/length-of-last-word
class Solution:
def lengthOfLastWord(self, s: str) -> int:
last_word = s.strip().split(' ').pop()
return len(last_word) if last_word != '' else 0