# strip and split
class Solution:
    def lengthOfLastWord(self, s: str) -> int:
        if len(s.strip()) == 0:
            return 0
        last_word = s[::-1].split()[0]
        return len(last_word)


# pointer (faster)
# time-O(n)
# space-O(1)
class Solution:
    def lengthOfLastWord(self, s: str) -> int: